0

来自 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 菜鸟警报!

4

1 回答 1

1

$back,在您看来,是一个数组。您将需要通过 index 访问特定项目<?=$back[0]->back_photo?>,或者将 custom_query 的签名更改为仅返回一项。

于 2013-06-20T15:06:37.837 回答