Cphalcon: All model attributes have string type

Created on 22 Aug 2019  路  2Comments  路  Source: phalcon/cphalcon

$days = HabitMark::find(['goal_id = ?0', 'bind' => [$this->id]])->toArray();
echo '<pre>';
var_dump($days);
exit();

array (size=1)
0 =>
array (size=5)
'goal_id' => string '116' (length=3)
'date' => string '2019-08-21' (length=10)
'status' => string '0' (length=1)
'days_count' => null
'date_fail' => null

But in DB fileds goal_id and status have integer type. How can I get attributes with correct types?

Details

  • Phalcon version: 4.0.0-beta.2
  • PHP Version: 7.2.18-1
  • Operating System: ubuntu16.04.1
  • Installation type: installing via package manager
  • Server: Nginx
not a bug

Most helpful comment

You can disable this behavior by setting:

'options'  => [
                PDO::ATTR_EMULATE_PREPARES   => false,
                PDO::ATTR_STRINGIFY_FETCHES  => false,
                PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
            ],

At least it works for me in 3.x

All 2 comments

Thank you for your intrest in Phalcon. This intended behavior. Please use github for bugs only.
For questions you can use Discord and the Forum
In the forum you will find some posts how to achieve this.

You can disable this behavior by setting:

'options'  => [
                PDO::ATTR_EMULATE_PREPARES   => false,
                PDO::ATTR_STRINGIFY_FETCHES  => false,
                PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
            ],

At least it works for me in 3.x

Was this page helpful?
0 / 5 - 0 ratings