これは私のクエリで、9行しか表示されませんが、日付で並べ替える方法と場所を追加する必要があります(現在のクエリで並べ替えます)
$q = $this->db->get('exchange_rate, country', 9,'exchange_rate.CountryId = country.CountryId');
これは私のクエリで、9行しか表示されませんが、日付で並べ替える方法と場所を追加する必要があります(現在のクエリで並べ替えます)
$q = $this->db->get('exchange_rate, country', 9,'exchange_rate.CountryId = country.CountryId');
例として、この形式を試してください
$this->db->select('a.exchange_rate, b.country');
$this->db->from('exchange_rate a');
$this->db->join('country b','b.CountryId = a.CountryId');
$this->db->order_by("yourOrderByColumn",'DESC');
$this->db->limit(9);
$query = $this->db->get();
http://ellislab.com/codeigniter/user-guide/database/active_record.html
あなたは codeignitor データベースの概念について良い考えを得るでしょう
$this->db->from('exchange_rate');
$this->db->join('country', 'exchange_rate.CountryId = country.CountryId');
$this->db->limit(9);
$this->db->order_by("date", "asc");
$query = $this->db->get();
詳細については、codeigniter のドキュメントを参照してください
まず、あなたはget()
メソッドをひどく間違って使用しています。その構文をどこで手に入れたのか、私にはわかりません。
はクエリをトリガーするメソッドであるためget()
、クエリの詳細を追加するすべてのパラメーター メソッドwhere()
( 、 など) は、その前にorder_by()
配置する必要があります。
$this->db->order_by('column', 'ASC');
$this->db->get('table_name');
また、奇妙なWHERE
順序で 2 つのテーブルを選択する代わりに、JOIN を使用することをお勧めします。
$this->db->select('column, another_column, etc');
$this->db->from('table');
$this->db->join('another_table', 'another_table.column = table.column');
$this->db->order_by('sort', 'DESC');
$query = $this->db->get();