Database - Phalcon\Db fetch constants

I don't know if it's a bug, but since you use the PDO layer, the constants for fetching records, should have the same value as in PDO.

For example, now you have:

const FETCHASSOC = 1; // Should be 2 const FETCHBOTH = 2; // Should be 4 const FETCHNUM = 3; // It is ok const FETCHOBJ = 4; // Should be 5 as in PDO

If you don't correct this, running the following code, will not return the records as expected (object)

    $db = $this->getDI()->get('db')->getInternalHandler();

    $result = $db->query($s_query);
    $result->setFetchMode(\Phalcon\Db::FETCH_OBJ);
    return $result->fetchAll();

But if you replace \Phalcon\Db::FETCHOBJ with 5 or \PDO::FETCHOBJ, it works as expected.

Phalcon 1.1.0



82.3k

When you get the internal handler you're working over the PDO instance and not with Phalcon\Db\Adapter*, of course you need to use PDO constants there



31.3k

Ok. Thank you.