本文整理汇总了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');
}
//.........这里部分代码省略.........