tags:

views:

19

answers:

1

Hi guys, i was wondering if you could point me in the right direction. Im extending the mysqli class but cant seem to call the error function..

<?php

class mysqli_ls extends mysqli
{
   private $activeConnection = 0;
   private $linkArr  = array();
   private $queryArr = array();
   private $errorArr = array();  

   public function __construct()
   {
   }

/* Connection ************************************************************ */

   public function connect($host='', $username='', $password='', $port='', $database='')
   {
      $no =& $this->activeConnection;
      $no++;

      if ( empty($host) || empty($username) || empty($password) || empty($port) || empty($database) )
      {
         $this->setError('1', 'connect','missing required variables');
         return false;
      }

      $this->linkArr[ $no ] = parent::mysqli($host,$username,$password);

      if ( $this->linkArr[ $no ] === false )
      {
         $this->setError(2, 'connect', parent::error( $this->linkArr[ $no ] ) );
         return false;
      }

      return $no;
   }

Fatal error: Call to undefined method mysqli::error() in C:\wamp\www\vhdocs\test\mysqli.class.php on line 31

i've also tried parent::mysqli_error and had the same error... I cant see why i cant call the error.....

+2  A: 

Try $this->error (it's a property, not a function in OO style). See also the examples at the php manual

Wrikken
Something is messing with my mind tonight... +1 to you.
BoltClock
I was indeed somewhat surprised by your remarks ;P
Wrikken
I have been reading.. it says a ref to the connection is required... so it is a function?
Lee
@Lee: it is only a function in procedural style (and _not_ a class method, but a real standalone function). You are working with the OO interface, so by all means, go for the _property_ it is at that point. So, either `$this->error` to get the error of the 'main' instance, or `$this->linkArr[$no]->error` to get them from the array of connections you seem to build.
Wrikken
@Wrikken: It's late :P What I'll need is **sleep** — my rep has already capped anyway...
BoltClock