query->result() returns empty
$query->result() is returning array{0} while $query->result_array() is returning correct result . driver odbc database informix
because of this fix https://github.com/EllisLab/CodeIgniter/issues/129 when using query->result() in my code result return 0 but when
public function num_rows()
{
if (is_int($this->num_rows))
{
return $this->num_rows;
}
// Work-around for ODBC subdrivers that don't support num_rows()
// if (($this->num_rows = @odbc_num_rows($this->result_id)) === -1)
// {
// $this->num_rows = count($this->result_array());
// }
return @odbc_num_rows($this->result_id);
}
result will return correct value and result_array will return correct value; num_rows still will return -1
i think this issue https://github.com/EllisLab/CodeIgniter/issues/129 should be reopen priority is to get the result.. num rows can be count after getting the result in controller of model
Sorry about that ... if we override the result_array() method with one that doesn't depend on num_rows(), it should be fine. Here's it is: https://github.com/EllisLab/CodeIgniter/commit/cc5af53346397846f2035dc2bf6a2c2f9b0cd4ab
I've tested it, but will leave this one open until you confirm.
i did several test.. $query->result() still return empty array ..
... _data_seek() sucks, here's another one: https://github.com/EllisLab/CodeIgniter/commit/9c68c3173c84041b1ee77929e540a4a4382edeee
nice.. everything works fine now.. result() , result_array(), and num_rows() is returning the correct value.
OK, closing this one then. :)
version: CodeIgniter 2.1.3 num_rows() return is 60+ , but $query->result() and $query->result_array() is both return empty .... please help me ~~~
I met the same error with whyb. $query->num_rows() return 19605 but $query->result_array() does not return anything. There are no errors found. 19605 records is not very large data, is it right? Please help.
@tthanhlong , my database driver is odbc, ms sql server, But I met the problem two year ago. I not sure the new version was resolved it?
Memory limit caused this problem. Default is 128M, but we can set memory_limit = 1024M or higher and you should be good.
ini_set('memory_limit', "1024M");
We also set unlimited by:
ini_set('memory_limit', "-1");
but it isn't be encouraged due to memory leak somewhere and out of control.
I changed to appropriate number and it seems to be fix.
Regards!