本文整理汇总了PHP中CDbCriteria::AddInCondition方法的典型用法代码示例。如果您正苦于以下问题:PHP CDbCriteria::AddInCondition方法的具体用法?PHP CDbCriteria::AddInCondition怎么用?PHP CDbCriteria::AddInCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDbCriteria
的用法示例。
在下文中一共展示了CDbCriteria::AddInCondition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
public function actionIndex($pid = 0)
{
$model = new uJournal();
$model->unsetAttributes();
$criteria = new CDbCriteria();
$criteria1 = new CDbCriteria();
$criteria->compare('module_id', 2);
$criteria->order = 't.yearmonth_periode DESC, t.created_date DESC';
//$criteria->compare('yearmonth_periode',Yii::app()->settings->get("System", "cCurrentPeriod"));
if ($pid != 0) {
$criteria->compare('journalDetail.account_no_id', $pid);
}
if (isset($_GET['uJournal'])) {
$model->attributes = $_GET['uJournal'];
$criteria1->compare('system_ref', $_GET['uJournal']['system_ref'], true, 'OR');
$criteria1->compare('remark', $_GET['uJournal']['system_ref'], true, 'OR');
}
if (Yii::app()->user->name != "admin") {
$criteria->AddInCondition('entity_id', sUser::model()->getGroupArray());
}
$criteria->mergeWith($criteria1);
$rawData = uJournal::model()->with('journalDetail')->findAll($criteria);
$dataProvider = new CArrayDataProvider($rawData, array('pagination' => array('pageSize' => 20)));
$this->render('index', array('dataProvider' => $dataProvider, 'model' => $model));
}
示例2: 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($id = 1)
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria = new CDbCriteria();
$criteria->compare('user_id', $this->user_id);
$criteria->compare('user_name', trim($this->user_name), true);
$criteria->compare('user_image', $this->user_image, true);
$criteria->compare('user_email', trim($this->user_email), true);
$criteria->compare('user_password', $this->user_password, true);
$criteria->compare('user_status', $this->user_status, true);
$criteria->compare('user_role_type', $this->user_role_type);
$criteria->compare('user_department_id', $this->user_department_id);
$criteria->compare('user_created_by_id', $this->user_created_by_id);
$criteria->compare('user_last_login_time', $this->user_last_login_time, true);
$criteria->compare('user_last_logout_time', $this->user_last_logout_time, true);
$criteria->compare('user_ip_address', $this->user_ip_address, true);
$criteria->compare('created_date', $this->created_date, true);
$criteria->compare('updated_date', $this->updated_date, true);
$criteria->compare('phone', $this->phone, true);
$criteria->compare('skype', $this->skype, true);
if ($id == 1) {
if ($this->getAllUserbyCreated(Yii::app()->session['user_data']['user_id'])) {
$criteria->AddInCondition('user_created_by_id ', $this->all);
}
$criteria->AddCondition('user_role_type != 5');
} else {
if (in_array(Yii::app()->session['user_data']['user_role_type'], array(0, 1, 2))) {
$criteria->AddCondition('user_role_type ==5');
} else {
$criteria->AddCondition('user_id==0 ');
}
}
return new CActiveDataProvider($this, array('criteria' => $criteria, 'sort' => array('defaultOrder' => 'user_id asc'), 'pagination' => array('pageSize' => 20)));
}
示例3: 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');
}
//.........这里部分代码省略.........