Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
DB::count_last_query() throws an error
  • 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
  • Shouldnt that line be just :

    return (int) $result->get('total_rows');
  • 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 ?
  • That is expected behaviour, the DBAL doesn't know where queries come from, it just uses the last one.
  • Fair enough,
    What about that error at line 390 ?
  • I have to look at it.
  • Harro VertonHarro Verton
    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. ;-)
  • Thank you!
  • Found another issue, so more updates are coming...
  • And also fixed.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion