0
下面的代碼是給我這個錯誤:PHP SQL與多個選擇不工作
Call to undefined method mysqli_stmt::get_result() on line 21.
我不明白這是如何工作的對象,爲什麼我可以做的第一個數據庫調用而不是第二。
<?php
header('Content-Type: application/json');
include_once 'do_dbConnect.php';
include_once 'functions.php';
sec_session_start();
//identify who took the last call
$stmt = $mysqli->stmt_init();
if ($stmt->prepare("SELECT MAX(dateOfCall), id FROM call")) { //setup the query statement
$stmt->execute(); //execute the statement
$result = $stmt->get_result(); //get the results
$row = $result->fetch_assoc(); //get the first row
$user_id = $row['id']; //get the id column
}
//identify how many team members there are
if ($stmt->prepare("SELECT id FROM teamMembers")) { //setup the query statement
$stmt->execute(); //execute the statement
$result = $stmt->get_result(); //get the results
$memberCount = $result->num_rows;
}
//get next user
if ($stmt = $mysqli->prepare("SELECT * FROM teamMembers WHERE id = (? + 1) % ?")) { //setup the query statement
$stmt->bind_param('ii', $user_id, $memberCount);
$stmt->execute(); //execute the statement
$result = $stmt->get_result(); //get the results
$row = $result->fetch_assoc(); //get the first row
$next_user_id = $row['id']; //get the id column
$next_user_name = $row['username'];
}
$stmt->close();
//get the next call taker from the teamMember table
echo json_encode($row);
?>
請指定哪些線是21 ??你怎麼知道第一個mysqli電話是好的? –
我不知道你的問題的答案,但我總是發現,理解事情的工作往往是最重要的一步。看到這個評論:http://stackoverflow.com/a/8343970/1888402另外,不要害羞,這是一個公共論壇,人們喜歡得到幫助人們的積分,因此這對所有參與者都是雙贏的。 –
一個問題是您的第一個查詢**調用**是您需要的[* Mysql保留關鍵字*](http://dev.mysql.com/doc/refman/5.6/en/reserved-words.html)用bact-ticks逃脫它 –