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

Queries to DB return string instead of defined type #318

Open
kazimirchuk opened this issue Feb 10, 2015 · 0 comments
Open

Queries to DB return string instead of defined type #318

kazimirchuk opened this issue Feb 10, 2015 · 0 comments

Comments

@kazimirchuk
Copy link

I have a table UsersCars where I store: "user_id", "car_id" and "airbags".
"car_id" and "airbags" are int columns, but when I try to get needed rows
from a table, I get them as strings.
Specifically I'm using:

$select = UsersCars\Table::select();
$select->select('car_id as carId, airbags')->where('user_id = ?', $userId);
return $select->execute();

It returns me:

array (size=1)
  0 => 
    object(Application\Garage\UsersCars\Row)[36]
      protected 'data' => 
        array (size=2)
          'carId' => string "3"
          'airbags' => string "8"

The problem is that I need carId and airbags as integers but I'm getting strings.
Surfing over the Internet I found the reason of such a strange behaviour. It is in
an installed php5-mysql driver.
To solve this problem I removed it and then installed php5-mysqlnd. Also I added
this to an application.config:

"db" => [
    "connect" => [
        "options" => [
            \PDO::ATTR_EMULATE_PREPARES => false
        ...
        ]
    ]
]

Maybe it will help somebody.

@AntonShevchuk AntonShevchuk modified the milestones: 8.0.0, 7.6.0 Apr 13, 2017
@AntonShevchuk AntonShevchuk modified the milestones: 7.6.0, 7.8.0 Aug 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants