来自print_r
Array (
[0] => stdClass Object (
[id] => 2729
[title] =>
[image_file] => M6_Black_Back.jpg
[product] => 2
[active] => 0
[created] => 2013-06-19 23:14:51
[rank] => 1
[publish] => 0
[back_photo] => M6_Black_Back.jpg
)
)
这是我的控制器
$data['back'] = $this->global_model->custom_query('
SELECT *,image_file AS back_photo FROM system_product_photos
WHERE product = 2 AND rank = 1
');
$this->load->view('template', $data);
我不能为我的生命让<?=$back->back_photo?>
输出任何东西。
警告codeignighter菜鸟警报!
答案 0 :(得分:1)
$back
是一个数组。您将需要按索引<?=$back[0]->back_photo?>
访问特定项目,或将custom_query的签名更改为仅返回一个项目。