從MYSQL切換到MYSQLi時出現問題。這些代碼可以在MYSQL下正常工作,但是當我將連接更改爲MYSQLi時,我在獲取我的查詢時收到上述錯誤。我如何使用mysqli函數獲取我的查詢?致命錯誤:調用未定義的方法mysqli_result :: rowCount()
代碼:
function __construct(){
$this->link = mysqli_connect('localhost', 'root', '', 'ajax_rating');
if (!$this->link) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
echo 'Success... ' . mysqli_get_host_info($this->link) . "\n";
}
function getItems($id = null){
if(isset($_GET['id']))
{
$query = $this->link->query("SELECT * FROM items WHERE id = '$id'");
}
else
{
$query = $this->link->query("SELECT * FROM items");
}
$rowCount = $query->rowCount();
if($rowCount >= 1)
{
$result = $query->fetchAll();
}
else
{
$result = 0;
}
return $result;
毫米我早些時候嘗試過,但它給了我「調用未定義的方法mysqli_result :: fetchAll()」我研究了aro和似乎我需要某種本地驅動程序? – suppko
該方法名稱更改。現在它被稱爲'mysqli_result :: fetch_all()'。結果集對象上的所有方法都記錄在這裏:http://php.net/manual/en/class.mysqli-result.php – staticsan