订购这是我的查询在那里我只显示9行,但whow按日期 如何和订购,我应该(在当前查询的顺序)加我笨如何通过这个查询
$q = $this->db->get('exchange_rate, country', 9,'exchange_rate.CountryId = country.CountryId');
订购这是我的查询在那里我只显示9行,但whow按日期 如何和订购,我应该(在当前查询的顺序)加我笨如何通过这个查询
$q = $this->db->get('exchange_rate, country', 9,'exchange_rate.CountryId = country.CountryId');
$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();
欲了解更多信息,请访问笨documentation
试这种格式,只是作为一个例子
$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 DATABSE conceepts好主意
首先,您使用的get()
method可怕的错误。你有什么语法,我不知道。
由于get()
是触发查询,所有参数的方法是添加查询的详细信息的方法 - 像where()
,order_by()
等 -它之前应该来。
$this->db->order_by('column', 'ASC');
$this->db->get('table_name');
我还建议使用连接而不是选择两个表与奇怪的WHERE
序列。
$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();
它工作我欣赏 – rafiq
请检查答案作为解决方案,如果它为你工作。 –
这工作得很好,我感谢你的帮助 我怎么能设置条件,例如活动= 1 – rafiq
$ this-> db->其中('active',1); – tuffkid