Welcome Guest, Not a member yet? Register   Sign In
oracle problem? 'ocifetchinto() expects parameter 1 to be resource, null given' ?
#1

[eluser]Unknown[/eluser]
Hi, everyone. :-)

Here I am, long time reader, first time poster, asking for your kind help with this rare problem.

After a week pulling my hair out, I've finally made the oci8 library work with PHP 5.2.4. As I have the Oracle 8i Client 8.1.7.0.0, I had to download the Oracle 10g Instant Client, reconfigure my path variable, edit my registry malformed NLS_LANG variable, etc. (more info here: http://tinyurl.com/34nzlt, http://tinyurl.com/enrtj and here http://tinyurl.com/2a9wo4).

Now I've been able to query a table from my oracle DB directrly through a PHP script:
Code:
$db_conn = ocilogon("user", "passwd", 'SID');

    $cmdstr = "select * from user_tables";

    $parsed = ociparse($db_conn, $cmdstr);
    ociexecute($parsed);

    $nrows = ocifetchstatement($parsed, $results);

    for ($i = 0; $i < $nrows; $i++ )
    {
      echo $results["TABLE_NAME"][$i];
      echo number_format($results["TABLESPACE_NAME"][$i],   2);
    }

But when I try to do a similar thing throu codeigniter, I get this output:

A PHP Error was encountered
Severity: Warning
Message: ocifetchinto() expects parameter 1 to be resource, null given
Filename: oci8/oci8_result.php
Line Number: 159

Any idea what could it mean? I'm thinking, some kind of incompatibility between the 8.1 and 9i version of my DB.

my config\database.php look like this:
Code:
$db['default']['hostname'] = "SID";
$db['default']['username'] = "user";
$db['default']['password'] = "passwd";
$db['default']['database'] = "";
$db['default']['dbdriver'] = "oci8";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";

and my model:

Code:
class Ora extends Model {
    function Ora()
    {   parent::Model();
        $this->load->database('default',TRUE);    }

    function get_sel()
    {   $query = $this->db->getwhere('month',array('month >' => '06'));
        return $query->result();}
}

after the ifrst error, it repeats this one several times:

A PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$nombre_mes
Filename: libraries/Loader.php(647) : eval()'d code
Line Number: 11

Now, the interesting thing is that it repeats this second error the same number of times as rows it should have returned, so as far as I can tell, it's getting the result; it just can't show it.

any ideas? thanks!
#2

[eluser]mhyk[/eluser]
i think it's a oci8 bug. I also have a problem with that.
#3

[eluser]crossett[/eluser]
Move the line of code that reads "$RES->num_rows = $RES->num_rows();" below the if block in system/database/DB_driver.php. It is around line 325.




$driver = $this->load_rdriver();
$RES = new $driver();
$RES->conn_id = $this->conn_id;
$RES->result_id = $this->result_id;

if ($this->dbdriver == 'oci8')
{
$RES->stmt_id = $this->stmt_id;
$RES->curs_id = NULL;
$RES->limit_used = $this->limit_used;
}

$RES->num_rows = $RES->num_rows();
#4

[eluser]411161[/eluser]
I tried that:

$driver = $this->load_rdriver();
$RES = new $driver();
$RES->conn_id = $this->conn_id;
$RES->result_id = $this->result_id;
//$RES->num_rows = $RES->num_rows();

if ($this->dbdriver == 'oci8')
{
$RES->stmt_id = $this->stmt_id;
$RES->curs_id = NULL;
$RES->limit_used = $this->limit_used;
}

//as411161 9/12/2008
$RES->num_rows = $RES->num_rows();


Did not work for me.
#5

[eluser]bakazero[/eluser]
@crossett
Thx! It's works for me like the magic!

@summer Student
Thx for you too! I'm using your database-config right now...

hmm...
Why not works for you?
Btw, I'm using codeigniter 1.6.3..

maybe you need upgrade your CI first...




Theme © iAndrew 2016 - Forum software by © MyBB