Вызов функции-члена bind_param () для не-объекта, не работающего внутри функции, вызванного из другой функции

Я получаю ошибку выше в функции get_template () моего класса, указанной ниже. Кто-нибудь знает, почему я получаю эту ошибку? Все остальные запросы выполняются отлично, и $ template_number, безусловно, возвращает int, который ожидается в этот момент запроса, поэтому почему я получаю эту ошибку? Может быть, потому, что возврат этого запроса отформатирован как TEXT в MySQL (и отображается как BLOB в PHPMyAdmin?

class Page{ private $con; public function __construct(Connection $con) { $this->con = $con; if(isset($_GET['id'])){ $id = $_GET['id']; }else{ $id = 1; } $this->get_headers($id); $this->get_content($id); $this->get_footer($id); } private function get_headers($pageId){ $retrieveHead = $this->con->prepare("SELECT headers FROM pages WHERE page_id=?"); $retrieveHead->bind_param('i',$pageId); $retrieveHead->execute(); $retrieveHead->bind_result($header); $retrieveHead->fetch(); $retrieveHead->close(); echo $header; } private function get_footer($pageId){ $retrieveFooter = $this->con->prepare("SELECT footer FROM pages WHERE page_id=?"); $retrieveFooter->bind_param('i',$pageId); $retrieveFooter->execute(); $retrieveFooter->bind_result($footer); $retrieveFooter->fetch(); $retrieveFooter->close(); echo $footer; } private function get_content($pageId){ $retreiveContent = $this->con->prepare("SELECT template_id, section_title, i1, i2 FROM content WHERE page_id=? ORDER BY sequence DESC"); $retreiveContent->bind_param('i',$pageId); $retreiveContent->execute(); $retreiveContent->bind_result($template_id, $section_title, $i1, $i2); while ($retreiveContent->fetch()) { //Variables will be populated for this row. //Update the tags in the template. $template = $this->get_template($template_id); $template = str_replace('[i1]',$i1,$template); $template = str_replace('[i2]',$i2,$template); //$theTemplate is populated with content. Probably want to echo here echo $template; } $retreiveContent->close(); } private function get_template($template_number){ $retreiveFunction = $this->con->prepare("SELECT code FROM templates WHERE template_id=?"); $retreiveFunction->bind_param('i',$template_number); $retreiveFunction->execute(); $retreiveFunction->bind_result($template); $retreiveFunction->fetch(); $retreiveFunction->close(); return $template; } } 

Структуру таблицы можно найти ниже:

Структура таблицы

Related of "Вызов функции-члена bind_param () для не-объекта, не работающего внутри функции, вызванного из другой функции"

Смотрите здесь и здесь . mysqli_stmt::execute() по умолчанию сохраняет серверы результатов и выбирает строку за строкой, если вы не вызываете mysqli_stmt::store_result() чтобы буферизовать их на стороне клиента. Попытка подготовить другое утверждение, скорее всего, не удастся, пока нет отступной стороны сервера от предыдущего заявления.

Для любого другого, кто ищет это решение, поскольку bwewing предлагает мне добавить в store_result, однако из приведенных выше ссылок не слишком ясно, где это должно быть реализовано.

Реализация должна выполняться в первом методе вызова. Таким образом, поскольку метод get_content () вызывает метод get_template (), он должен быть реализован здесь следующим образом:

  private function get_content($pageId){ $retreiveContent = $this->con->prepare("SELECT template_id, section_title, i1, i2 FROM content WHERE page_id=? ORDER BY sequence DESC"); $retreiveContent->bind_param('i',$pageId); $retreiveContent->execute(); $retreiveContent->bind_result($template_id, $section_title, $i1, $i2); $retreiveContent->store_result(); while ($retreiveContent->fetch()) { //Variables will be populated for this row. //Update the tags in the template. $template = $this->get_template($template_id); $template = str_replace('[i1]',$i1,$template); $template = str_replace('[i2]',$i2,$template); //$theTemplate is populated with content. Probably want to echo here echo $template; } $retreiveContent->free_result(); $retreiveContent->close(); }