在我的 php 代码中,我在普通 SQL 之前调用存储过程(链接:SELECT * FROM TABLE
;)查询运行。对于该存储过程运行,但普通 SQL 无法运行。在这两种情况下我都使用 mysql_query() 。但是当我运行正常的 SQL 时,它会同时运行。
我有一个具有 mysql_query() 的类 dataManager
这是我的代码:
require_once 'DL/DataManager.php'; require_once 'utils/Utils.php'; require_once 'DL/class/event/Event.php';
$Utils = new Utils();
$obj = new Event();
$result = array();
$result = $obj->get_all_event_data("NULL"); //Query = "CALL events_all_data(" . $ID . ");";
echo date("y-m-d h:i:s")."<br />";
echo $Utils->getString_UserName_ByUserID( "23" )."<br />"; // Not Run Query = SELECT `USER_NICK` FROM `USER_INFO` WHERE `USER_ID` ='".$string ."';";
数据管理器.php
public function openConnection() { $this->connection = mysql_connect($this->HostName, $this->UserName, $this->PassWord); if (!$this->connection) { return mysql_error(); } mysql_select_db($this->DataBase); return $this->connection; }
执行sql查询
public function retrieveData($Query = "")
{
//$Query = mysql_real_escape_string($Query);
//echo "DB retriveData query : ".$Query. " <br />";
$data = mysql_query($Query);
$num_rows = mysql_num_rows($data);
//echo "db ret number : ".$num_rows." asdas: ". "\n";
if($num_rows)
{
$this->Data = array();
//$i = 0;
while ($mat[] = mysql_fetch_row($data));
//echo $mat[$i++][2]."<br />";
$this->Data = $mat;
//print_r($this->Data);
//$result = $this->getArrayTranspose($mat);
}
else
{
$this->Data = NULL;
}
//return $result;
}
连接关闭
public function closeConnection()
{
if(!$this->connection)
{
mysql_close ();
return ;
}
else if($this->connection == NULL)
{
mysql_close ();
return ;
}
else if(!isset($this->connection))
{
mysql_close ();
return ;
}
else if(is_resource($this->connection))
{
mysql_close($this->connection);
return ;
}
else
{
//mysql_close();
}
}