Jump to content

Class extension problem. Please help


Hubgoblin

Recommended Posts

Hello, I'm trying to extent mysqli native class and I have the following problems. When I call parent::connect() the function never returns any result and I cannot recieve the connection identifier. Also parent::query() returns true and not a real result. Please tell me what is goin on. I'll post the entire class.
[code]
<?php
class SQL extends mysqli
{
public $connection;

public $statement;

public $autocommit = false;

public $dbPrefix = null;

public function __construct( $params )
{

$this->connect($params);
}

public function connect( $params )
{
$this->dbPrefix = isset($params['prefix'])?$params['prefix']:null;

@$this->connection = parent::connect
(
$params['host'],
$params['user'],
$params['pass'],
$params['base']
);

// !!!!!!!!!!!!!!!!!!!!!!!
echo '<pre>';var_dump($this->connection);echo '</pre>';
die(__METHOD__.__FILE__);

// Why $this->connection is null)

if    (mysqli_connect_error())
throw new Exception(mysqli_connect_error());

// managing transactions autommit property

parent::autocommit($this->autocommit);

/**
mysqli pepared statements managing object

@var : Object
@param  : Object
@return  : Object
@example : http://bg.php.net/manual/en/function.mysqli-stmt-prepare.php
*/

$this->statement =& new mysqli_stmt($this);
}

public function disconnect()
{
$this->close($this->connection);
}

/**
Free result
@deprecated
*/
public function free(){}

public function prefix()
{
return $this->dbPrefix;
}

public function query( $sql )
{
if (!($result = parent::query($sql)))
      {
          die(sprintf("Can't perform query on database. Error: %s", $this->error));
      }
      return $result;
}

public function getAll( $sql )
{
$res = $this->query($sql);

}
public function getOne( $sql )
{

}

public function getLastInsertID()
{
return mysqli_insert_id();
}
public function getRows(){}

public function getAffectedRows()
{
return mysqli_affected_rows();
}
}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/33437-class-extension-problem-please-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.