CodeIgniter Forums
Oracle driver and $this->db->count_all() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Oracle driver and $this->db->count_all() (/thread-14297.html)



Oracle driver and $this->db->count_all() - El Forum - 12-27-2008

[eluser]Unknown[/eluser]
Hi.

Not sure if this has been brought up anywhere, apologies if it has. Please feel free to move this post if its in the wrong place.

Issue encountered on : CI 1.7 on Apache/2.2.9 (Win32) DAV/2 mod_ssl/2.2.9 OpenSSL/0.9.8i mod_autoindex_color PHP/5.2.6.

Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$NUMROWS

Filename: oci8/oci8_driver.php

Line Number: 438

Error appears to be caused by $NUMROWS on line 438 (/system/database/oci8/oci8_driver.php) being capitalised. Please see the below fix. It is working thus far.

Before:

Code:
function count_all($table = '')
    {
        if ($table == '')
            return '0';

        $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows'). " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));

        if ($query == FALSE)
            {
            return 0;
            }

        $row = $query->row();
        return $row->NUMROWS;

After:
Code:
function count_all($table = '')
    {
        if ($table == '')
            return '0';

        $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows'). " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));

        if ($query == FALSE)
            {
            return 0;
            }

        $row = $query->row();
        return $row->numrows;
    }

shoutout to the following posts : http://www.abbett.org/2007/12/02/using-oracle-with-php-and-codeigniter/ and http://techxplorer.com/2008/11/03/using-codeigniter-with-an-oracle-database/

Thanks


Oracle driver and $this->db->count_all() - El Forum - 12-29-2008

[eluser]Michael Wales[/eluser]
I've moved this to the bug reports forum - additionally, I would ask that you file a ticket within the Bug Tracker if it has not already been done.


Oracle driver and $this->db->count_all() - El Forum - 07-10-2009

[eluser]phpworker[/eluser]
Hi! Just want to say that have the same problem and the above solution not solved that problem for CI 1.7.1, PHP5 and Oracle 10g. I'll post the solution if I find nice one...


Oracle driver and $this->db->count_all() - El Forum - 02-27-2011

[eluser]Unknown[/eluser]
sorry for bumping the old thread...

I'm working with CI 2.0 + Oracle 10g

i think this

Code:
return (int) $row->numrows;

should be reverted to

Code:
return (int) $row->NUMROWS;

since oracle always returned all fields name capitalized by default