[英]Codeigniter, Select, Result, Array Format
我正在使用Codeigniter,我从两个表( country
和city
)中选择了所有(*)数据。 这些表都有一个ID
字段,当我打印结果时,数组中只有一个ID
元素。
国家表的字段:
城市表的字段:
这是我的代码点火器代码:
$this->db->select('country.*, city.*');
$this->db->from('country');
$this->db->join('city', 'city.ctry_id = country.id', 'left');
$this->db->where('country.name', 'Tajikistan');
$qry = $this->db->get();
// Testing purpose only [do not judge ;)]
echo '<pre>';
print_r($qry->result());
echo '</pre>';
预期结果:
id => 1,
name => 'Tajikistan',
flag => 'tj.png',
president => 'Emomali Rahmon',
id => 1,
ctry_id => 1,
name => 'Dushanbe'
.
.
.
我得到的结果是:
id => 1,
name => 'Dushanbe',
flag => 'tj.png',
president => 'Emomali Rahmon',
ctry_id => 1
.
.
.
任何帮助将不胜感激。
我使用化名或每列的前缀解决了这个“问题”,例如:
The country table's fields:
ctry_id;
ctry_name;
ctry_flag;
ctry_president.
The city table's fields:
cty_id;
cty_ctry_id; (country id)
cty_name.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.