簡體   English   中英

Codeigniter,選擇,結果,數組格式

[英]Codeigniter, Select, Result, Array Format

我正在使用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
.
.
.

任何幫助將不勝感激。

我使用化名或每列的前綴解決了這個“問題”,例如:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM