Codeigniter 2.x, ActiveRecord, var_dump(), 预期结果是什么?

Codeigniter 2.x, ActiveRecord, var_dump(), what is the expected result?

我正在尝试调试在查看数据库数据时遇到的一些问题。我正在使用 codeigniter 2.x 和活动记录。这是我的代码:

$data = $this->db->select('country_id', 'country')->from('mhcountry')->get()->result();

    var_dump($data);
    die;    

Var_dump returns 以下内容:

array(20) { [0]=> object(stdClass)#21 (1) { ["country_id"]=> string(1) "1" } [1]=> object(stdClass)#22 (1) { ["country_id"]=> string(1) "2" } [2]=> object(stdClass)#23 (1) { ["country_id"]=> string(1) "3" } [3]=> object(stdClass)#24 (1) { ["country_id"]=> string(1) "4" } [4]=> object(stdClass)#25 (1) { ["country_id"]=> string(1) "5" } [5]=> object(stdClass)#26 (1) { ["country_id"]=> string(1) "6" } [6]=> object(stdClass)#27 (1) { ["country_id"]=> string(1) "7" } [7]=> object(stdClass)#28 (1) { ["country_id"]=> string(1) "8" } [8]=> object(stdClass)#29 (1) { ["country_id"]=> string(1) "9" } [9]=> object(stdClass)#30 (1) { ["country_id"]=> string(2) "10" } [10]=> object(stdClass)#31 (1) { ["country_id"]=> string(2) "11" } [11]=> object(stdClass)#32 (1) { ["country_id"]=> string(2) "12" } [12]=> object(stdClass)#33 (1) { ["country_id"]=> string(2) "13" } [13]=> object(stdClass)#34 (1) { ["country_id"]=> string(2) "14" } [14]=> object(stdClass)#35 (1) { ["country_id"]=> string(2) "15" } [15]=> object(stdClass)#36 (1) { ["country_id"]=> string(2) "16" } [16]=> object(stdClass)#37 (1) { ["country_id"]=> string(2) "17" } [17]=> object(stdClass)#38 (1) { ["country_id"]=> string(2) "18" } [18]=> object(stdClass)#39 (1) { ["country_id"]=> string(2) "19" } [19]=> object(stdClass)#40 (1) { ["country_id"]=> string(2) "20" } }

我从 1 到 20 输入了 20 个国家,但我在 var_dump 中没有看到我的国家名称。它只是倾倒第一个字段。这是正常的还是预期的?

我在另一个 table 上尝试了同样的事情,它也只是 returns 第一个字段。

$data = $this->db->select('country_id', 'country')->from('mhcountry')->get()->result();

这是错误的。它只会得到 country_id.
使用这个

$data = $this->db->select('country_id , country')->from('mhcountry')->get()->result();

你应该注意文档here,同时你可以试试这个:

$this->db->select(array('country_id', 'country'))
// OR
$this->db->select('country_id, country')