Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
DB::count_last_query() throws an error
disperse
May 2018
Morning Harro,
Following last update, we now see another issue:
\DB::select('*')
->from('table')
->execute()
->as_array();
\DB::count_last_query();
Fuel\Core\PhpErrorException [ Notice ]:
Trying to get property of non-object
/classes/database/connection.php @ line 390
disperse
May 2018
Shouldnt that line be just :
return (int) $result->get('total_rows');
disperse
May 2018
After investigating this a little bit deeper I've found this:
\DB::select('*')
->from('table')
->execute()
->as_array();
echo \DB::count_last_query(); // returns 21 as a correct result
echo \DB::count_last_query(); // returns 1 as the count query was the last executed one
The question is : is that expected behavior or it should not replace context of initial query ?
Harro
May 2018
That is expected behaviour, the DBAL doesn't know where queries come from, it just uses the last one.
disperse
May 2018
Fair enough,
What about that error at line 390 ?
Harro
May 2018
I have to look at it.
Harro
May 2018
Accepted Answer
Fixed.
Also count_last_query() no longer resets the "last query" in the system, so the expected behaviour is now also a more logical behaviour.
;-)
disperse
May 2018
Thank you!
Harro
May 2018
Found another issue, so more updates are coming...
Harro
May 2018
And also fixed.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
disperse
May 2018
Harro
May 2018