num_rows() returns -1 even when there are rows |
[eluser]whirled[/eluser]
Hi, I am querying a MS Access database for a login controller, and was testing for the record count using the num_rows() method. I kept getting an error saying no records were returned from my code based on the number returned, and after echoing out the result of num_rows() I noticed that it was always -1, even when print_r($query->result_array()) displays the data that was returned. Is this just a limitation of querying an Access database? Thanks, William
[eluser]InsiteFX[/eluser]
What database driver are you using? For access I think you need to use the odbc driver. InsiteFX
[eluser]whirled[/eluser]
Hi, The ODBC driver is being used. Also, in case this helps, the site is running on a Windows 2003 server using Zend Server CE with Apache. The MS Access DB is 2007. The connection works fine, and I am able to read records using the active record methods, but num_rows() always returns -1. The contents of my database.php file: Code: $db['default']['hostname'] = 'ZendServer_MSAccess_Database'; The code from my model: Code: $query = $this->db->get_where('UsersTable', array('Emails' => $email)); Result of num_rows() and print_r of result_array(): Code: -1 Thanks for the help. -William
[eluser]whirled[/eluser]
Query is: Code: $query = $this->db->get_where('UsersTable', array('Emails' => $email)); Checking by using: Code: $query->num_rows(); I also tried using Code: $query = $this->db->query("Select * from UsersTable"); num_rows() still returns -1, even though data is retrieved. Thanks, -William
[eluser]InsiteFX[/eluser]
num_rows() should either return 0 or the number of rows it found not -1 This could be a bug so you would have to report it to the CodeIgniter Reactor Team! CodeIgniter Reactor - Issues Ok, I just did some checking and found this out! Code: // odbc_num_rows for access does return -1. I use InsiteFX |
Welcome Guest, Not a member yet? Register Sign In |