Welcome Guest, Not a member yet? Register   Sign In
Oracle driver and $this->db->count_all()
#1

[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-o...deigniter/ and http://techxplorer.com/2008/11/03/using-...-database/

Thanks
#2

[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.
#3

[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...
#4

[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




Theme © iAndrew 2016 - Forum software by © MyBB