Codeigniter,选择,结果,数组格式

萨利姆·伊布罗吉莫夫(Salim Ibrogimov)

我使用的是Codeigniter,我从两个表(countrycity)中选择了所有(*)数据这些表都有一个ID字段,当我打印结果时ID,数组中只有一个元素。

国家表的字段:

  1. ID;
  2. 名称;
  3. 旗;
  4. 总统。

城市表的字段:

  1. ID;
  2. ctry_id; (国家/地区编号)
  3. 名称。

这是我的代码点火器代码:

$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
.
.
.

任何帮助将不胜感激。

萨利姆·伊布罗吉莫夫(Salim Ibrogimov)

我使用化名或每列的前缀解决了这个“问题”,例如:

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.

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章