當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CDbCriteria::Addcondition方法代碼示例

本文整理匯總了PHP中CDbCriteria::Addcondition方法的典型用法代碼示例。如果您正苦於以下問題:PHP CDbCriteria::Addcondition方法的具體用法?PHP CDbCriteria::Addcondition怎麽用?PHP CDbCriteria::Addcondition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CDbCriteria的用法示例。


在下文中一共展示了CDbCriteria::Addcondition方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: search

 /**
  * Retrieves a list of models based on the current search/filter conditions.
  *
  * Typical usecase:
  * - Initialize the model fields with values from filter form.
  * - Execute this method to get CActiveDataProvider instance which will filter
  * models according to data in model fields.
  * - Pass data provider to CGridView, CListView or any similar widget.
  *
  * @return CActiveDataProvider the data provider that can return the models
  * based on the search/filter conditions.
  */
 public function search()
 {
     // @todo Please modify the following code to remove attributes that should not be searched.
     $criteria = new CDbCriteria();
     $client_name = isset($_GET['Ticket']['clientname']) ? $_GET['Ticket']['clientname'] : '';
     $criteria->compare('ticket_id', trim($this->ticket_id), true);
     $criteria->compare('candidate_key', trim($this->candidate_key), true);
     $criteria->compare('ticket_title', trim($this->ticket_title), true);
     if (!empty($client_name)) {
         $clients = Users::model()->getAllClients($client_name);
         //print_r($clients);
         $clientsList = implode(",", $clients);
         $ordlists = Orders::model()->findAllByAttributes(array(), 'client_id in (' . $clientsList . ')');
         $ordlist = array();
         foreach ($ordlists as $single) {
             $ordlist[] = $single->order_id;
         }
         $criteria->AddInCondition('order_id', $ordlist);
     } else {
         $criteria->compare('order_id', trim($this->order_id));
     }
     $criteria->compare('description', trim($this->description), true);
     $criteria->compare('department_id', $this->department_id);
     $criteria->compare('ticket_resolve_date', $this->ticket_resolve_date, true);
     $criteria->compare('ticket_status', $this->ticket_status);
     $criteria->compare('closed_at', $this->closed_at, true);
     $criteria->compare('closed_by', $this->closed_by);
     $criteria->compare('read_by', $this->read_by, true);
     $criteria->compare('read', $this->read, true);
     $criteria->compare('close_reason', $this->close_reason, true);
     $criteria->compare('created_date', $this->created_date, true);
     $criteria->compare('updated_date', $this->updated_date, true);
     if (!in_array(Yii::app()->session['user_data']['user_role_type'], array(0, 1, 2))) {
         $ticketList = TicketAssign::model()->getTicketbyUser(Yii::app()->session['user_data']['user_id']);
         $ticket_ids = array();
         foreach ($ticketList as $ticket) {
             $ticket_ids[] = $ticket['ticket_id'];
         }
         if (!empty($ticket_ids)) {
             $criteria->AddInCondition('ticket_id', $ticket_ids);
         } else {
             if (!isset($_GET['clientsTicket'])) {
                 $criteria->addCondition('ticket_id==0');
             }
         }
         //             if (!isset($_GET['clientsTicket'])) {
         //               $criteria->AddCondition('ticket_status !=1');
         //             }
     } else {
         if (isset($_GET['user_id'])) {
             $ticketList = TicketAssign::model()->getTicketbyUser(Yii::app()->session['user_data']['user_id']);
             $ticket_ids = array();
             foreach ($ticketList as $ticket) {
                 $ticket_ids[] = $ticket['ticket_id'];
             }
             if (!empty($ticket_ids)) {
                 $criteria->AddInCondition('ticket_id', $ticket_ids);
             } else {
                 $criteria->Addcondition('ticket_id==0');
             }
         }
     }
     if (isset($_GET['ts'])) {
         if (isset($_GET['Ticket']['ticket_status'])) {
             $_GET['ts'] = $_GET['Ticket']['ticket_status'];
         }
         $ts = $_GET['ts'];
         if ($ts) {
             $criteria->AddCondition('ticket_status ==' . $ts);
         }
     }
     if (isset($_GET['client'])) {
         $client_id = base64_decode($_GET['client']);
         $order_ids = Ticket::Orderlistbyclients($client_id);
         if (!empty($order_ids)) {
             $criteria->AddInCondition('order_id', $order_ids);
         } else {
             $criteria->Addcondition('order_id==0');
         }
     }
     if (isset($_GET['clientsTicket'])) {
         $client_id = base64_decode($_GET['clientsTicket']);
         $order_ids = Ticket::Orderlistbyclients($client_id);
         if (!empty($order_ids)) {
             $criteria->AddInCondition('order_id', $order_ids);
         } else {
             $criteria->Addcondition('order_id==0');
         }
//.........這裏部分代碼省略.........
開發者ID:bhaiyyalal,項目名稱:testcode,代碼行數:101,代碼來源:Ticket.php


注:本文中的CDbCriteria::Addcondition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。