2013-10-03 50 views
0

我試圖返回部分結果,我希望Active Record可以手動處理分頁,因爲mssql不支持偏移量。但是下面的代碼不能按預期方式工作。CodeIgniter Active Record限制不適用於MSSQL

public function get_companies($search,$start,$limit) 
{ 
    $this->aws = $this->load->database('aws', TRUE); 
    $this->aws->select('*'); 
    $this->aws->from('_companies'); 
    $this->aws->order_by("Company"); 
    **$this->aws->limit($start, $limit);** 
    $this->aws->like('Company', $search); 
    $query = $this->aws->get(); 
    return $query->result_array(); 
} 
+0

在限制CI活動記錄是不同的Mysql和MSSql。閱讀:http://ellislab.com/forums/viewthread/160626/。也許會幫助你。 –

回答

1

我已經完成了使用限制的代碼,它對我來說工作得很好。

public function get_user_list($limit=0,$offset=0) 
{ 
    $this->db->select('*');  

    if(isset($limit)&& $limit!='')  
    {   
     $this->db->limit($limit, $offset);  
    } 

    $this->db->from(USER_TABLE_NAME);  

    if(isset($condition) && $condition != '')  
    {    
     $this->db->where($condition);   
    } 

    $this->db->order_by("firstname", "asc");  
    $query = $this->db->get();  
    echo $this->db->last_query(); // To Get Whole SQL Query 
    return $query->result_array(); 

}

最好的運氣

1

笨從V2.2領先支持100%所有可用的驅動程序limit()方法。

相關問題