Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some DbAdapter driver_options can make DbSelect::count() incorrect #10

Closed
richcem opened this issue Jul 29, 2020 · 2 comments · Fixed by #11
Closed

some DbAdapter driver_options can make DbSelect::count() incorrect #10

richcem opened this issue Jul 29, 2020 · 2 comments · Fixed by #11
Labels
Bug Something isn't working Unit Test Needed
Milestone

Comments

@richcem
Copy link

richcem commented Jul 29, 2020

Bug Report

some DbAdapter driver_options can make DbSelect::count() incorrect

Q A
Version(s) 2.8.2

Summary

PDO::CASE_LOWER can make DbSelect::count() incorrect.

Current behavior

get NOTICE: Undefined index: C on xxxxx

How to reproduce

$adapter = new Adapter([
            'driver'   => 'pdo_mysql',
            "driver_options" => [
                \PDO::ATTR_CASE => \PDO::CASE_LOWER,
            ],
         // other options ....
]);

$select = $sql->select();

$dbSelect = new DbSelect($select, xxxx)
$dbSelect->count();

// NOTICE: Undefined index: C on xxxxx
// DbSelect::count()
public function count()
    {
        if ($this->rowCount !== null) {
            return $this->rowCount;
        }

        $select = $this->getSelectCount();

        $statement = $this->sql->prepareStatementForSqlObject($select);
        $result    = $statement->execute();
        $row       = $result->current();

        // !!! here return $row['c'] = 10,lower case key

        $this->rowCount = (int) $row[self::ROW_COUNT_COLUMN_NAME];

        return $this->rowCount;
    }

Expected behavior

check lower or upper case key,return the right count

@froschdesign froschdesign added Bug Something isn't working Unit Test Needed labels Jul 29, 2020
@froschdesign froschdesign added this to the 2.8.4 milestone Jul 29, 2020
samsonasik added a commit to samsonasik/laminas-paginator that referenced this issue Aug 5, 2020
…ATTR_CASE => \PDO::CASE_LOWER in driver options

Signed-off-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
@samsonasik
Copy link
Member

samsonasik commented Aug 5, 2020

I created PR #11 for it. Haven't added unit test yet ...

samsonasik added a commit to samsonasik/laminas-paginator that referenced this issue Aug 5, 2020
…en setted \PDO::ATTR_CASE => \PDO::CASE_LOWER in driver options

Signed-off-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
@weierophinney
Copy link
Member

Fixed with #11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Unit Test Needed
Projects
None yet
4 participants