wzhw666 发表于 2009-3-19 16:03:50

CI中的数据返回

$this->db->get('table')这个方法,返回的数据没有我想要的,打印出来是这样的:
object(CI_DB_mysql_result)#12 (7) {
["conn_id"]=>
resource(28) of type (mysql link persistent)
["result_id"]=>
resource(29) of type (mysql result)
["result_array"]=>
array(0) {
}
["result_object"]=>
array(0) {
}
["current_row"]=>
int(0)
["num_rows"]=>
int(3)
["row_data"]=>
NULL

}



我想得到的键值应该是 id和name
这个是怎么回事呢?

Hex 发表于 2009-3-19 16:05:46

看 http://codeigniter.org.cn/user_guide/database/results.html

moorland 发表于 2009-3-20 18:00:52

$query = $this->db->get('table');

foreach ($query->result() as $row)
{
    echo $row->id;
    echo $row->name;
}

playgirl 发表于 2009-3-22 19:56:45

数组的返回值不是那么得到的
页: [1]
查看完整版本: CI中的数据返回