I have problem with loosing connections when working with mysqli. I've made class for manipulating mysqli queries to work with stored procedures, and discovered that after first execution of query with stored procedure - I can not execute second store procedure !?!?!?
constatly I get error "mysqli_error() expects exactly 1 parameter, 0 given"
mysql server version 5.0.51a-3ubuntu5.1
WHY ???
How can I fix this?
here is whole class
Code: Select all
<?php
class MySqliClass
{
var $Username;
var $Password;
var $Server;
var $Port;
var $Database;
var $Connection;
var $Result;
var $MysqlArray;
var $Query;
function MySqliClass($Server, $username, $Password, $Database, $Port)
{
$this->Username = $username;
$this->Password = $Password;
$this->Server = $Server;
$this->Port = $Port;
$this->Database = $Database;
$this->MakeConnection();
}
function MakeConnection()
{
if((!empty($this->Username)) && (!empty($this->Password)) && (!empty($this->Server)) && (!empty($this->Port)))
{
$this->Connection = mysqli_connect($this->Server,$this->Username,$this->Password,$this->Database, $this->Port);
return $this->Connection;
}
}
function ExecuteQuery($Query)
{
if($this->Connection)
{
if(!empty($Query))
{
$this->Query = $Query;
$this->Result = mysqli_query($this->Connection, $this->Query) or die (mysqli_error());
}
if($this->Result)
{
return $this->Result;
}
else
{
return;
}
}
}
function GetMysqlArray()
{
if($this->Result)
{
$this->MysqlArray = mysqli_fetch_array($this->Result);
return $this->MysqlArray;
}
}
function FreeResult()
{
if($this->Result)
{
mysqli_free_result($this->Result);
}
}
function CloseConnection()
{
if($this->Connection)
{
mysqli_close($this->Connection);
}
}
}
Code: Select all
$DB = new MySqliClass("hostname", "username", "password", "tablename", "3306");
$DB->ExecuteQuery("call firstSP('value1')");
while($rez = $DB->GetMysqlArray())
{
$r[] = $rez[0];
}
$DB->ExecuteQuery("call secondSP(value2)");
$w = $DB->GetMysqlArray();
please if somebody can point me in right direction ???
Thank you
kind regards
ddragas