MySQL을 MySQLi로 변환하려고합니다. 그리고MySQLi 중첩 준비 문을 구현하는 방법은 무엇입니까?
$stmt2->execute();
에 왜 브레이크를 파악하고 오류를 반환 할 수 없습니다
Call to a member function execute() on a non-object
어떤 문제 나 유효 그것의 구현!?
// SQL condition "WHERE group=''" where `group` is empty (NULL)
$result = "SELECT id, name FROM table WHERE group='' ORDER BY array ASC";
if ($stmt = $mysqli->prepare($result)) {
$stmt->execute();
$stmt->bind_result($id, $name);
while ($stmt->fetch()) {
// SQL condition "WHERE group='$id'" where $id defined in $stmt->bind_result($id, $name);
$result2 = "SELECT name FROM table WHERE group='$id' ORDER BY array ASC";
$stmt2 = $mysqli->prepare($result2);
//$valid_stmt2 = $stmt2 === FALSE ? false : true;
echo $name . "\n";
//if ($valid_stmt2) {
// Error cased on $stmt2->execute();
$stmt2->execute();
$stmt2->bind_result($name2);
while ($stmt2->fetch()) {
echo 'related to: ' . $name2 . "\n";
}
$stmt2->close();
//}
}
$stmt->free_result();
$stmt->close();
}
은이 질문은 불행하게도 나는 그것이 도움이 유효한 예를 제공하거나 문제에 대한 자원하지 않기 때문에 찾지 못했습니다 Possible to use multiple/nested MySQLi statements?과 관련이있을 수 있습니다.
업데이트 : 주석이있는 단순화 된 코드 예.
@hakre http://stackoverflow.com/questions/8999691/call의 중복이 아닙니다. -to-a-member-function-on-a-non-object를 사용합니다. 나는 $ stmt2 = $ mysqli-> prepare ("SELECT url, name FROM links where group = '?'ORDER BY array ASC");를 변경하고'$ stmt2-> bind_param ("i", $ id);를 추가했다. ',하지만 여전히 작동하지 않습니다. 누구나 실제 예제를 제공 할 수 있습니까? 두 번째'while()'은 첫 번째'while()'의'$ id' 조건을 기반으로 쿼리 결과를 반환해야합니다. – Binyamin
커뮤니티가이 질문을 http://stackoverflow.com/questions/8999691/call-to-a-member-function-execute-on-a-non-object와 정확히 일치하는 것으로 보는 방법에 대해 어리석은 말입니다. 요청 된 재확인. – Binyamin