0

これは私のクエリで、9行しか表示されませんが、日付で並べ替える方法と場所を追加する必要があります(現在のクエリで並べ替えます)

$q = $this->db->get('exchange_rate, country', 9,'exchange_rate.CountryId = country.CountryId');
4

4 に答える 4

0

例として、この形式を試してください

         $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();
于 2013-03-29T07:33:45.777 に答える
0

http://ellislab.com/codeigniter/user-guide/database/active_record.html

あなたは codeignitor データベースの概念について良い考えを得るでしょう

于 2013-03-29T07:34:32.820 に答える
0
$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 のドキュメントを参照してください

于 2013-03-29T07:36:53.920 に答える
0

まず、あなたは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();
于 2013-03-29T07:38:30.507 に答える