PHP: $result = $this->db->query("SELECT * FROM oc_news INNER JOIN oc_news_to_category WHERE oc_news_to_category.news_id = '1';"); foreach ($result as $res) { //print_r($v); //echo $res['image']; }
Ок. PHP: $result = $this->db->query("SELECT * FROM oc_news INNER JOIN oc_news_to_category WHERE oc_news_to_category.news_id = '1';"); $i = 0 foreach ($result as $res) { echo $res[$i]["image"]; $i++; }
Fatal error: Cannot use object of type stdClass as array in C:\AppServ\www\catalog\view\theme\default\template\common\column_right.tpl on line 15
Notice: Undefined variable: res in C:\AppServ\www\catalog\view\theme\default\template\common\column_right.tpl on line 16 Fatal error: Call to a member function fetch() on a non-object in C:\AppServ\www\catalog\view\theme\default\template\common\column_right.tpl on line 16 --- Добавлено --- если $res = $this->db->query("SELECT * FROM oc_news INNER JOIN oc_news_to_category WHERE oc_news_to_category.news_id = '1';"); то выдает Fatal error: Call to undefined method stdClass::fetch() in C:\AppServ\www\catalog\view\theme\default\template\common\column_right.tpl on line 16
Оу, я же не знаю какой там метод для обработки... Погоди, щас погуглю --- Добавлено --- Вот, нашёл пример в документации: PHP: $query = $this->db->query("SELECT * FROM oc_news INNER JOIN oc_news_to_category WHERE oc_news_to_category.news_id = '1';"); foreach ($query->result() as $row) { echo $row->image; } --- Добавлено --- Или PHP: foreach ($query->result_array() as $row) { echo $row['image']; }
такс. первый вариант Fatal error: Call to undefined method stdClass::result() in C:\AppServ\www\catalog\view\theme\default\template\common\column_right.tpl on line 16 второй Fatal error: Call to undefined method stdClass::result_array() in C:\AppServ\www\catalog\view\theme\default\template\common\column_right.tpl on line 16
Ну тогда точно не знаю... Эти методы показаны в документации... А если всунуть это перед запросом $this->load->database();?