• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
unbuffered_row() not working - returning null

#1
I'm having trouble with the unbuffered_row() function which doesn't seem to be working at all in CI_VERSION = 3.0.6

In this snippet, the die() never triggers (even though there are definitely results)

PHP Code:
    $sql "SELECT * FROM some_table";
    $query $this->db->query($sql);
    while ($row $query->unbuffered_row()) {
        die('here');
    

In this example, the var_dump returns NULL

PHP Code:
    $sql "SELECT * FROM some_table";
    $query $this->db->query($sql);
    var_dump($query->unbuffered_row()); 

I've followed the documentation, brief as it is on the subject. Is this a bug in the framework or am I missing something obvious?
Reply

#2
The method can return false or null if there are any errors in the request or an empty result.
Depends on the type of driver selected.
Null can be returned by sqlsrv and mysqli drivers

Try to query the database using native php functions to check.
Reply

#3
(03-09-2021, 08:55 AM)iRedds Wrote: The method can return false or null if there are any errors in the request or an empty result.
Depends on the type of driver selected.
Null can be returned by sqlsrv and mysqli drivers

Try to query the database using native php functions to check.

Thanks for the reply. There is definitely data returned by the query. If I do a result() instead:

PHP Code:
$this->db->query($sql)->result() 

It returns results (except I have to increase `memory_limit` to actually avoid memory exhausted errors)
Reply

#4
I will show you how it works so you can understand.

Call result()
result() -> result_object() -> _fetch_object() -> working with native php DBSM function

Call unbuffered_row()
unbuffered_row() -> _fetch_object() -> working with native php DBSM function

That is, the only difference is in result_object(), where _fetch_object() is called in a loop.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.