[英]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.