本文整理汇总了PHP中CDbCriteria::AddCondition方法的典型用法代码示例。如果您正苦于以下问题:PHP CDbCriteria::AddCondition方法的具体用法?PHP CDbCriteria::AddCondition怎么用?PHP CDbCriteria::AddCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDbCriteria
的用法示例。
在下文中一共展示了CDbCriteria::AddCondition方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: searchAdmin
public function searchAdmin($criteria = null)
{
if (is_null($criteria)) {
$criteria = new CDbCriteria();
}
$criteria->select = "t.*,GROUP_CONCAT(concat(ecer_descr,' [',ecer_status,']') SEPARATOR '<br/>') error";
$criteria->join = "LEFT OUTER JOIN ecer_errors ON ecer_ecnt_id = ecnt_id";
$criteria->group = "ecnt_id";
if (!empty($this->ecnt_datetime_range)) {
$criteria->AddCondition("t.ecnt_datetime >= '" . substr($this->ecnt_datetime_range, 0, 10) . "'");
$criteria->AddCondition("t.ecnt_datetime <= '" . substr($this->ecnt_datetime_range, -10) . "'");
}
return new CActiveDataProvider(get_class($this), array('criteria' => $this->searchCriteria($criteria), 'sort' => array('defaultOrder' => 'ecnt_datetime DESC')));
}
示例2: searchCriteria
public function searchCriteria($criteria = null)
{
if (is_null($criteria)) {
$criteria = new CDbCriteria();
}
if (!empty($this->task_name)) {
$criteria->join .= ' inner join ttsk_task on tcmn_ttsk_id = ttsk_id ';
$criteria->compare('ttsk_name', $this->task_name, true);
}
if (!empty($this->tcmn_date_range)) {
$criteria->AddCondition("tcmn_datetime >= '" . substr($this->tcmn_date_range, 0, 10) . "'");
$criteria->AddCondition("tcmn_datetime <= '" . substr($this->tcmn_date_range, -10) . "'");
}
return parent::searchCriteria($criteria);
}
示例3: searchCriteria
public function searchCriteria($criteria = null)
{
if (is_null($criteria)) {
$criteria = new CDbCriteria();
}
if (!empty($this->person_list)) {
$criteria->join .= ' inner join tprs_persons on ttsk_id = tprs_ttsk_id ';
$criteria->compare('tprs_pprs_id', $this->person_list);
}
if (!empty($this->tcmn_date_range)) {
$criteria->join .= ' inner join tcmn_communication on ttsk_id = tcmn_ttsk_id ';
$criteria->AddCondition("tcmn_datetime >= '" . substr($this->tcmn_date_range, 0, 10) . "'");
$criteria->AddCondition("tcmn_datetime <= '" . substr($this->tcmn_date_range, -10) . "'");
}
return parent::searchCriteria($criteria);
}
示例4: onUploadPhoto
/**
* Attached event for anytime a product photo is uploaded
* @param $event
* @return bool
*/
public function onUploadPhoto($event)
{
//We were passed these by the CEventPhoto class
$blbImage = $event->blbImage;
//$image resource
$objProduct = $event->objProduct;
$intSequence = $event->intSequence;
//Check to see if we have an Image record already
$criteria = new CDbCriteria();
$criteria->AddCondition("`product_id`=:product_id");
$criteria->AddCondition("`index`=:index");
$criteria->AddCondition("`parent`=`id`");
$criteria->params = array(':index' => $intSequence, ':product_id' => $objProduct->id);
$objImage = Images::model()->find($criteria);
if (!$objImage instanceof Images) {
$objImage = new Images();
} else {
$objImage->DeleteImage();
}
//Assign width and height of original
$objImage->width = imagesx($blbImage);
$objImage->height = imagesy($blbImage);
//Assign filename this image, actually write the binary file
$strImageName = Images::AssignImageName($objProduct, $intSequence);
$objImage->SaveImageData($strImageName, $blbImage);
$objImage->product_id = $objProduct->id;
$objImage->index = $intSequence;
//Save image record
Yii::trace("saving {$strImageName}", 'application.' . __CLASS__ . "." . __FUNCTION__);
if (!$objImage->save()) {
Yii::log("Error saving image " . print_r($objImage->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
return false;
}
$objImage->parent = $objImage->id;
//Assign parent to self
$objImage->save();
//Update product record with imageid if this is a primary
if ($intSequence == 0) {
$objProduct->image_id = $objImage->id;
if (!$objProduct->save()) {
Yii::log("Error updating product " . print_r($objProduct->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
return false;
}
}
$this->createThumbnails($objImage);
return true;
}
示例5: findhMonth
public function findhMonth($month)
{
$sql = "set @month = :month";
$rawData = Yii::app()->db->createCommand($sql);
$rawData->bindParam(":month", $month, PDO::PARAM_STR);
$rawData->query();
$criteria = new CDbCriteria();
//filtrēšana pēc mēneša
$criteria->AddCondition("cled_date >= ADDDATE(concat(@month,'-01',-1) \n AND cled_date <= ADDDATE(@month,'-01', INTERVAL 1 MONTH )");
$criteria->order = 'cled_date';
return self::model()->findAll($criteria);
}
示例6: GetOriginal
public static function GetOriginal($objProduct)
{
//Check to see if we have an Image record already
$criteria = new CDbCriteria();
$criteria->AddCondition("`product_id`=:product_id");
$criteria->AddCondition("`index`=:index");
$criteria->AddCondition("`parent`=`id`");
$criteria->params = array(':index' => 0, ':product_id' => $objProduct->id);
return Images::model()->find($criteria);
}
示例7: actionIntsubcats
/**
* When a category is chosen, find subcategories available for that selection
*/
public function actionIntsubcats()
{
$service = Yii::app()->getRequest()->getQuery('service');
$intLevel = Yii::app()->getRequest()->getQuery('lv');
$intSelected = Yii::app()->getRequest()->getQuery('selected');
$strModelName = "Category" . ucfirst($service);
//Model for 3rd party service
$objPicked = $strModelName::model()->findByPk($intSelected);
if ($intLevel < 1 || $intLevel > 9) {
$intLevel = 1;
}
$strNext = "name" . ($intLevel + 1);
$strAfter = "name" . ($intLevel + 2);
$criteria = new CDbCriteria();
$criteria->select = 't.id,t.' . $strNext;
$criteria->order = $strNext;
$arrParam = array();
for ($x = 1; $x <= $intLevel; $x++) {
$criteria->AddCondition("name" . $x . "=:name" . $x);
$strThis = "name" . $x;
$arrParam[':name' . $x] = $objPicked->{$strThis};
}
$criteria->AddCondition($strNext . " is NOT NULL");
$criteria->AddCondition($strAfter . " is NULL");
$criteria->params = $arrParam;
$arrReturn['cats'] = CHtml::listData($strModelName::model()->findAll($criteria), 'id', $strNext);
if (isset($objPicked->product_type)) {
$arrReturn['producttypes'] = $this->getProductTypes($objPicked->product_type);
}
echo json_encode($arrReturn);
}
示例8: 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)));
}
示例9: array
<?php
//We cheat a bit and use google naming on some field so our CSS still works
switch ($_GET['item']) {
case 'name0':
echo '<div class="restrictions">';
$form = $this->beginWidget('CActiveForm', array('id' => 'googlecats', 'enableAjaxValidation' => false, 'enableClientValidation' => false));
echo '<h4>Editing: ' . $strRequestUrl . '</h4><div class="ginstructions">Choose the most appropriate ' . ucfirst($service) . ' category path for this item. Choose subcategories as needed. If the next dropdown remains dark, that means there are no additional levels for that category. ' . $strModelName::getInstructions() . '</div>';
echo '<form>';
$criteria = new CDbCriteria();
$criteria->select = 't.id, t.name1';
$criteria->AddCondition("name2 is NULL");
$criteria->order = "name1";
$arrCats = CHtml::listData($strModelName::model()->findAll($criteria), 'id', 'name1');
echo $form->dropdownList($model, 'id', $arrCats, array('id' => 'name1', 'class' => 'tinyfont googleselect', 'prompt' => '--Choose--'));
for ($x = 2; $x <= 7; $x++) {
echo '<br>' . str_repeat(' ', $x * 2) . '<select disabled="true" name="name' . $x . '" id="name' . $x . '" class="tinyfont googleselect" >';
echo '<option value="0">';
echo '</select>';
}
if ($service == "google") {
echo '<div id="extra" class="extra">' . str_repeat(' ', $x * 2) . ' Required for Apparel & Accessories only: <b>Gender</b> <select name="googleg" id="googleg" class="tinyfont" >';
echo '<option value="Unisex">Unisex';
echo '<option value="Male">Male';
echo '<option value="Female">Female';
echo '</select> ';
echo '<b>Age</b> <select name="googlea" id="googlea" class="tinyfont" >';
echo '<option value="Adult">Adult';
echo '<option value="Kids">Kids';
echo '</select></div>';
}
示例10: actionList_articles
/**
* Список статей для разных вкладок
*/
public function actionList_articles()
{
$criteria = new CDbCriteria();
$criteria->with = array('idCategory0', 'idMenu0', 'idUser0', 'commentsCount', 'tagstoarticles');
$criteria->condition = 'moderationAppruv = 1 AND public = 1 AND deleted = 0';
if (isset($_GET['listType']) || isset($_POST['listType'])) {
$listType = isset($_GET['listType']) ? $_GET['listType'] : $_POST['listType'];
} else {
$listType = 'main';
}
switch ($listType) {
case 'razdel':
if (isset($_GET['idMenu'])) {
$this->breadcrumbs = AuxiliaryFunctions::fillingBreadcrumbs($_GET['idMenu'], 'mainMenu');
$criteria->AddCondition('t.idMenu = :idMenu');
$criteria->params = array(':idMenu' => $_GET['idMenu']);
}
$criteria->order = 'dateCreate DESC';
$this->_listCategory = Categorys::getAllCategories($_GET['idMenu'], true, true);
$this->render('_list_articles', $this->getArticlesDataProvider($criteria));
break;
case 'category':
if (isset($_GET['idMenu']) && isset($_GET['idCategory'])) {
$this->breadcrumbs = AuxiliaryFunctions::fillingBreadcrumbs($_GET['idCategory'], 'category');
$criteria->AddCondition('t.idMenu = :idMenu AND t.idCategory = :idCategory');
$criteria->params = array(':idMenu' => $_GET['idMenu'], ':idCategory' => $_GET['idCategory']);
}
$criteria->order = 'dateCreate DESC';
$this->_listCategory = Categorys::getAllCategories($_GET['idMenu'], true, true);
$this->render('_list_articles', $this->getArticlesDataProvider($criteria));
break;
case 'tags':
if (isset($_GET['idTag'])) {
$idTag = trim(htmlspecialchars($_GET['idTag']));
$criteria->join = 'INNER JOIN tagstoarticles AS t2a ON t2a.idTag = ' . $idTag . '';
$criteria->AddCondition('t2a.idArticle = t.idArticle');
}
$criteria->order = 'dateCreate DESC';
$this->render('_list_articles', $this->getArticlesDataProvider($criteria));
break;
case 'search':
if (isset($_POST['soughtValue'])) {
$searchResult = Articles::model()->getListArticles($_POST['soughtValue']);
if (!empty($searchResult)) {
$dataProvider = new CArrayDataProvider($searchResult, array('keyField' => 'idArticle'));
$popup = $this->renderPartial('_list_articles_search', array('dataProvider' => $dataProvider), true);
echo CJSON::encode(array('popup' => $popup));
exit;
} else {
echo CJSON::encode(array('result' => null));
exit;
}
}
break;
case 'cabinet_appruve':
$criteria->condition = 'moderationAppruv = 0 AND deleted = 0';
if (Yii::app()->user->id) {
$criteria->AddCondition('t.idUser = :idUser');
$criteria->params = array(':idUser' => Yii::app()->user->id);
$criteria->order = 'dateCreate DESC';
$popup = $this->renderPartial('_list_articles_cabinet', $this->getArticlesDataProvider($criteria), true);
echo CJSON::encode(array('popup' => $popup));
exit;
}
break;
case 'cabinet_public':
if (Yii::app()->user->id) {
$criteria->AddCondition('t.idUser = :idUser');
$criteria->params = array(':idUser' => Yii::app()->user->id);
$criteria->order = 'dateCreate DESC';
$popup = $this->renderPartial('_list_articles_cabinet', $this->getArticlesDataProvider($criteria), true);
echo CJSON::encode(array('popup' => $popup));
exit;
}
break;
case 'cabinet_bookmarks':
if (Yii::app()->user->id) {
if (isset($_POST['idMenu'])) {
$criteria->join = 'INNER JOIN bookmarks AS b ON b.idUser = ' . Yii::app()->user->id . ' AND b.idArticle = t.idArticle';
$criteria->AddCondition('t.idMenu = :idMenu');
$criteria->params = array(':idMenu' => $_POST['idMenu']);
if (isset($_POST['idCategory'])) {
$criteria->AddCondition('t.idCategory = :idCategory');
$criteria->params[':idCategory'] = $_POST['idCategory'];
}
}
$criteria->order = 'dateCreate DESC';
$popup = $this->renderPartial('_list_articles_cabinet', $this->getArticlesDataProvider($criteria), true);
echo CJSON::encode(array('popup' => $popup));
exit;
}
break;
}
}
示例11: 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');
}
//.........这里部分代码省略.........
示例12: RemoveImageFromS3
public function RemoveImageFromS3($objImage, $image_path = null)
{
$this->init();
$s3 = new S3($_SERVER['amazon_key'], $_SERVER['amazon_secret']);
if (is_null($image_path)) {
$criteria = new CDbCriteria();
$criteria->AddCondition("`product_id`=:product_id");
$criteria->AddCondition("`index`=:index");
$criteria->params = array(':index' => $objImage->index, ':product_id' => $objImage->product_id);
$objImages = Images::model()->findAll($criteria);
foreach ($objImages as $image) {
Yii::log("Attempting to delete " . $image->image_path, 'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
$key = str_replace("//lightspeedwebstore.s3.amazonaws.com/", "", $image->image_path);
if (!empty($image->image_path)) {
$s3->deleteObject('lightspeedwebstore', $key);
}
}
} else {
$image_path = str_replace("http:", "", $image_path);
$image_path = str_replace("//lightspeedwebstore.s3.amazonaws.com/", "", $image_path);
$s3->deleteObject('lightspeedwebstore', $image_path);
}
}