usmanhalalit / pixie

Database query builder for PHP, framework agnostic, lightweight and expressive.
MIT License
672 stars 180 forks source link

Specifying FetchMode with options #185

Closed vikkio88 closed 6 years ago

vikkio88 commented 6 years ago

I tried to specify to fetch mode globally with 'options'

'options' => [
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
]

but basically that does not matter because it is set anyway on ->get() via

$result = call_user_func_array(array($this->pdoStatement, 'fetchAll'), $this->fetchParameters);

on https://github.com/usmanhalalit/pixie/blob/master/src/Pixie/QueryBuilder/QueryBuilderHandler.php#L178

And if you try to set it on the QueryBuilderHandler using the setFetchMode() method, you will lose it next time you are going to use a ->table(), as it is creating a new instance of QB.

TCB13 commented 6 years ago

You're correct and we have been over this in the past. #143. They only place where FETCH_MODE is kept is between raw queries #68. This would be a nice improvement but @usmanhalalit probably need to check it.

vikkio88 commented 6 years ago

I opened a PR with a possible fix https://github.com/usmanhalalit/pixie/pull/183