Part of the EllisLab Network
   
 
oracle problem? ‘ocifetchinto() expects parameter 1 to be resource, null given’ ?
Posted: 22 October 2007 12:40 PM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  3
Joined  10-22-2007

Hi, everyone.  grin

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:

$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:

$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:

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!

Profile
 
 
Posted: 24 October 2007 03:34 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  5
Joined  10-24-2007

i think it’s a oci8 bug. I also have a problem with that.

Profile
 
 
Posted: 25 October 2007 02:11 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  3
Joined  10-25-2007

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();

Profile
 
 
Posted: 12 September 2008 02:07 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  3
Joined  09-12-2008

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.

Profile
 
 
Posted: 25 September 2008 10:37 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  2
Joined  09-25-2008

@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…

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 721, on January 06, 2010 09:38 AM
Total Registered Members: 114897 Total Logged-in Users: 37
Total Topics: 122389 Total Anonymous Users: 2
Total Replies: 647052 Total Guests: 373
Total Posts: 769441    
Members ( View Memberlist )