我使用OOP概念,從而使用的mysqli連接到我的數據庫,但在這裏我得到的「數據庫查詢不同步的,你無法運行此命令」的錯誤這就是爲什麼我使用mysqli免費的結果,現在我沒有收到任何數據作爲輸出。什麼可能是錯誤?無數據接收錯誤的mysqli免費結果
下面是我的數據庫連接類
class MySQLDatabase{
private $connection;
public $last_query;
private $magic_quotes_active;
private $real_escape_string_exists;
function __construct()
{
$this->open_connection();
$this->magic_quotes_active = get_magic_quotes_gpc();
$this->real_escape_string_exists = function_exists("mysqli_real_escape_string");
}
public function open_connection()
{
$this->connection=mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB_NAME) ;
mysqli_set_charset($this->connection,"utf8");
if(!$this->connection)
{
die("database connecetion failed".mysqli_error($this->connection));
}
}
public function close_connection()
{
if(isset($this->connection))
{
mysqli_close($this->connection);
unset($this->connection);
}
}
public function fetch($result_set)
{
return mysqli_fetch_array($result_set);
}
public function query($sql)
{
$this->last_query=$sql;
$result=$this->connection->query($sql);
if(!$result)
{
die("database query failed ".mysqli_error($this->connection));
}
return $result;
}
public function free_result($result)
{
return $this->free_result($result);
}
}
$database=new MySQLDatabase();
這是我怎麼稱呼我的程序,但因爲沒有收到數據,我不知道是什麼問題
$qryCallImgProc = "CALL description (".$postId.","."@commentOutput,@likeCount,@commentCount)";
$exeCallIgProc = $database->query($qryCallImgProc);
while($row = $database->fetch($exeCallIgProc))
{
print_r($row);
}
$database->free_result($exeCallIgProc);
$database->close_connection();
$qryLikeCount = "SELECT * from user";
$exeLikeCount = $database->query($qryLikeCount);
while ($fetchDetails = $database->fetch($exeLikeCount)) {
print_r($fetchDetails);
}
你的'free_result()'方法正在調用它自己。 – shudder 2014-09-01 05:51:02
它工作時,我取代$ this-> free_result($結果);與mysqli_free_result($ reult),但是當我打電話給我的過程@commentOutput是一個輸出參數,它給va; ue作爲空我檢查運行在工作臺評論輸出值不爲null – 2014-09-01 06:38:10