分页过滤器和订单

时间:2014-04-04 17:59:40

标签: cakephp pagination

我需要使用DESC订单日期来过滤寻呼机,我已经尝试了但仍然不适合我,任何想法的朋友?

public function admin_index(){
    $this->layout = "admin_default";
    $conditions = array('status'=>1);
    $filter = array();
    if(!empty($this->request->query)){
        $search = basicsLix::removeAcutes('%'.$this->request['url']['search'].'%');
        $filter = $this->request->query;
        $conditions += array('OR' => array(
                    basicsLix::removeSpecialCharacter('purchaser_name')=>$search),
                    'order'=>array( 'payment_date' => 'asc'));
    }
    $purchases = $this->paginate('Purchase', $conditions);
    $this->set(compact('purchases', 'filter'));
}

错误:

Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order = ('asc') LIMIT 20' at line 1

SQL查询:SELECT PurchaseidPurchasetrack_idPurchasepurchase_orderPurchase。{ {1}},purchaser_namePurchasepurchaser_emailPurchaseamountPurchasestatus。{{1 },PurchasedispatchedPurchasemethodPurchasepayment_datePurchasehashPurchasecreated FROM Purchasemodified AS resultados_tagid WHERE purchases = 1 AND CONVERT(CAST(UPPER)(TRAR(REPLACE) (REPLACE(buyerser,',',''),'。',''),' - ','')))二进制)使用utf8)LIKE' %%' AND order =(' asc')LIMIT 20

1 个答案:

答案 0 :(得分:0)

试试这个 -

if(!empty($this->request->query)){
    $search = basicsLix::removeAcutes('%'.$this->request['url']['search'].'%');
    $filter = $this->request->query;
    $conditions += array('OR' => array(
                basicsLix::removeSpecialCharacter('purchaser_name')=>$search)),
    $conditions['order']=array( 'payment_date' => 'asc');
}