本文整理汇总了PHP中CDbCriteria::addColumnCondition方法的典型用法代码示例。如果您正苦于以下问题:PHP CDbCriteria::addColumnCondition方法的具体用法?PHP CDbCriteria::addColumnCondition怎么用?PHP CDbCriteria::addColumnCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDbCriteria
的用法示例。
在下文中一共展示了CDbCriteria::addColumnCondition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$voting = null;
if (is_numeric(HU::post('id_voting'))) {
$voting = Voting::model()->onlyActive()->with('answer')->findByPk(HU::post('id_voting'));
}
if ($voting == null) {
//echo CHtml::encode($this->controller->widget('vote.widgets.VoteWidget', null, true));
return;
}
if (Yii::app()->vote->check($voting->id_voting)) {
$answers = $_POST['VotingAnswer']['name'];
$cr = new CDbCriteria();
$cr->addColumnCondition(array('id_voting' => $voting->id_voting));
if (is_array($answers)) {
$cr->addInCondition('id_voting_answer', $answers);
} else {
if (is_numeric($answers)) {
$cr->addColumnCondition(array('id_voting_answer' => $answers));
}
}
VotingAnswer::model()->updateCounters(array('count' => 1), $cr);
VisitSite::saveCurrentVisit(Voting::ID_OBJECT, $voting->id_voting);
Yii::app()->user->setState('vote_' . $voting->id_voting, time());
// перегружаем голосовалку, чтоб обновились показатели счетчиков
$voting = Voting::model()->onlyActive()->with('answer')->findByPk($voting->id_voting);
}
$voteCount = $voting->getSumVote();
echo CHtml::encode($this->controller->renderPartial("vote.widgets.views.statistic", array('voting' => $voting, 'voteCount' => $voteCount)), null, true);
}
示例2: run
public function run()
{
$this->controller->_seoTitle = '交易记录 - ' . $this->controller->_setting['site_name'];
$this->controller->loadModel();
$model = new UserTrade();
$criteria = new CDbCriteria();
//查询条件
$create_time_start = Yii::app()->request->getParam('create_time_start');
$create_time_end = Yii::app()->request->getParam('create_time_end');
$trade_type = Yii::app()->request->getParam('trade_type');
$trade_status = Yii::app()->request->getParam('trade_status');
$create_time_start && $criteria->addBetweenCondition('time_create', strtotime($create_time_start), strtotime($create_time_end));
if ($trade_type && $trade_type != 'all') {
$criteria->addColumnCondition(['type' => $trade_type]);
}
if ($trade_status && $trade_status != 'all') {
$criteria->addColumnCondition(['status' => $trade_status]);
}
$criteria->addColumnCondition(array('user_id' => Yii::app()->user->id));
$count = $model->count($criteria);
$pages = new CPagination($count);
$pages->pageSize = 10;
$pages->applyLimit($criteria);
$lists = $model->findAll($criteria);
//加载css js
Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/jquery/jquery.js");
Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/My97DatePicker/WdatePicker.js", CClientScript::POS_END);
$this->controller->render('list_trade', array('lists' => $lists, 'pages' => $pages, 'create_time_start' => $create_time_start, 'create_time_end' => $create_time_end, 'trade_type' => $trade_type, 'trade_status' => $trade_status));
}
示例3: run
public function run()
{
$model = new Comment();
//条件
$criteria = new CDbCriteria();
$type = trim(Yii::app()->request->getParam('type'));
$type && $criteria->addColumnCondition(array('type' => $type));
$status = trim(Yii::app()->request->getParam('status'));
$status && $criteria->addColumnCondition(array('status' => $status));
$title = trim(Yii::app()->request->getParam('content'));
$title && $criteria->addSearchCondition('content', $title);
$criteria->order = 't.id DESC';
$count = $model->count($criteria);
//分页
$pages = new CPagination($count);
$pages->pageSize = 10;
$pages->applyLimit($criteria);
//查询
$result = $model->findAll($criteria);
//全部类型
$model_types = ModelType::model()->findAll();
Yii::app()->clientScript->registerCssFile($this->controller->_static_public . "/js/kindeditor/code/prettify.css");
Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END);
$this->controller->render('index', array('model' => $model, 'model_types' => $model_types, 'datalist' => $result, 'pagebar' => $pages));
}
示例4: check
public static function check($idObject, $idInstance, $type, $ip, $expired, $countRepeats = 1)
{
$validIp = true;
if ($expired > 0) {
$expired = time() - $expired;
$digitalIp = $ip;
if (is_string($ip)) {
$digitalIp = ip2long($ip);
}
$criteria = new CDbCriteria();
$criteria->addCondition('date>:date');
$criteria->params = array(':date' => $expired);
$criteria->addColumnCondition(array('type_visit' => $type, 'ip' => $digitalIp, 'id_object' => $idObject));
if ($idInstance != null) {
$criteria->addColumnCondition(array('id_instance' => $idInstance));
}
$count = self::model()->count($criteria);
if ($count < $countRepeats) {
$validIp = true;
} else {
$validIp = false;
}
}
return $validIp;
}
示例5: search
public function search()
{
$criteria = new CDbCriteria();
if ($this->comment_id) {
if ($this->comment_id) {
$criteria->addColumnCondition(array('t.id' => $this->comment_id));
}
} else {
if ($this->post_id) {
$criteria->addColumnCondition(array('t.post_id' => $this->post_id));
}
if ($this->user_id) {
$criteria->addColumnCondition(array('t.user_id' => $this->user_id));
}
if ($this->user_name) {
$criteria->addColumnCondition(array('t.user_name' => $this->user_name));
}
if ($this->keyword) {
$criteria->addSearchCondition('t.content', $this->keyword);
}
if ($this->start_create_time || $this->end_create_time) {
$criteria->addCondition(array('and', 't.create_time > :starttime', 't.create_time < :endtime'));
$starttime = (int) $this->start_create_time ? strtotime($this->start_create_time) : 0;
$endtime = (int) $this->end_create_time ? strtotime($this->end_create_time) : $_SERVER['REQUEST_TIME'];
$params = array(':starttime' => $starttime, ':endtime' => $endtime);
$criteria->params = array_merge($criteria->params, $params);
}
}
$data = $criteria->condition ? AdminComment::fetchList($criteria) : null;
return $data;
}
示例6: byUnicName
public function byUnicName($unicName)
{
$criteria = new CDbCriteria();
$criteria->addColumnCondition(array('unique_name' => $unicName));
$this->getDbCriteria()->mergeWith($criteria);
return $this;
}
示例7: getRootNode
public function getRootNode()
{
$criteria = new CDbCriteria();
$criteria->addColumnCondition(array('decisiontree_id' => $this->id, 'parent_id' => null));
$node = OphCoTherapyapplication_DecisionTreeNode::model()->find($criteria);
return $node;
}
示例8: actionAutoComplete
/**
* Search the local authorities and return both their address and the address of their social security department
*
* @param $term
*/
public function actionAutoComplete($term)
{
$crit = new \CDbCriteria();
// NOTE: have commented out the address eager loading here due to column ambiguity issues with the relation definitions.
// need to investigate if this can be solved with the cunning use of scopes on the Contact model or not.
$crit->with = array('contact' => array('alias' => 'service_contact'), 'commissioning_body', 'commissioning_body.contact', 'type' => array('alias' => 'service_type'), 'commissioning_body.type' => array('alias' => 'body_type'));
$crit->compare('LOWER(t.name)', strtolower($term), true);
$crit->compare('LOWER(commissioning_body.name)', strtolower($term), true, 'OR');
$crit->addColumnCondition(array('service_type.shortname' => 'SSD'));
$crit->addColumnCondition(array('body_type.shortname' => 'LA'));
$crit->order = 'commissioning_body.name, t.name';
$results = array();
$found_bodies = array();
foreach (\CommissioningBodyService::model()->findAll($crit) as $cbs) {
$body = $cbs->commissioning_body;
$found_bodies[] = $body->id;
$results[] = array('id' => 'service' . $cbs->id, 'value' => $cbs->name . " ({$body->name})", 'service' => array('id' => $cbs->id, 'name' => $cbs->name, 'address' => $cbs->getLetterAddress(array('delimiter' => ",\n")), 'telephone' => $cbs->contact->primary_phone), 'body' => array('id' => $body->id, 'name' => $body->name, 'address' => $body->getLetterAddress(array('delimiter' => ",\n")), 'telephone' => $body->contact->primary_phone));
}
$body_crit = new \CDbCriteria();
$body_crit->with = array('type', 'contact', 'contact.correspondAddress');
$body_crit->compare('LOWER(t.name)', strtolower($term), true);
$body_crit->addNotInCondition('t.id', $found_bodies);
$body_crit->addColumnCondition(array('type.shortname' => 'LA'));
foreach (\CommissioningBody::model()->findAll($body_crit) as $body) {
$results[] = array('id' => 'body' . $body->id, 'value' => $body->name, 'body' => array('id' => $body->id, 'name' => $body->name, 'address' => $body->getLetterAddress(array('delimiter' => ",\n")), 'telephone' => $body->contact->primary_phone));
}
echo json_encode($results);
}
示例9: fetchPosts
private function fetchPosts()
{
$criteria = new CDbCriteria();
$criteria->select = array('id', 'category_id', 'topic_id', 'title', 'create_time', 'comment_nums', 'digg_nums', 'visit_nums', 'state');
$criteria->order = 'create_time desc';
$criteria->limit = $this->count;
if ($this->cid) {
$criteria->addColumnCondition(array('category_id' => $this->cid));
}
if ($this->tid) {
$criteria->addColumnCondition(array('topic_id' => $this->tid));
}
$criteria->addColumnCondition(array('t.state' => POST_STATE_ENABLED));
$models = Post::model()->findAll($criteria);
return (array) $models;
}
示例10: run
public function run()
{
$controller = $this->getController();
$controller->_seoTitle = Yii::t('common', 'User Center') . ' - ' . Yii::t('common', 'My Replys') . ' - ' . $controller->_setting['site_name'];
//我的回复
$uid = Yii::app()->user->id;
$comment_mod = new Comment();
$reply_mod = new Reply();
$criteria = new CDbCriteria();
$criteria->addColumnCondition(array('t.user_id' => $uid));
$criteria->order = 't.id DESC';
//分页
$count = $reply_mod->count($criteria);
$pages = new CPagination($count);
$pages->pageSize = 15;
$pages->applyLimit($criteria);
$datalist = $reply_mod->findAll($criteria);
foreach ((array) $datalist as $k => $v) {
$reply = $comment_mod->findByPk($v->cid);
if ($reply) {
$c_mod_class = $controller->_content_models[$reply->type];
$c_mod_name = strtolower($c_mod_class);
$content_mod = new $c_mod_class();
$content = $content_mod->findByPk($reply->content_id);
$datalist[$k]['title'] = $content->title;
$datalist[$k]['url'] = $controller->createUrl($c_mod_name . '/view', array('id' => $reply->content_id));
}
}
$controller->render('my_replys', array('datalist' => $datalist, 'pages' => $pages));
}
示例11: actionVerify
public function actionVerify()
{
$criteria = new CDbCriteria();
$criteria->addColumnCondition(array('state' => Post::STATE_DISABLED));
$data = self::fetchList($criteria);
$this->render('list', $data);
}
示例12: search
public function search()
{
$criteria = new CDbCriteria();
if ($this->postid) {
$criteria->addColumnCondition(array('t.id' => $this->postid));
} else {
if ($this->author) {
$criteria->addColumnCondition(array('t.contributor' => $author, 't.user_name' => $this->author), 'OR');
}
if ($this->keyword) {
$criteria->addSearchCondition('t.title', $this->keyword);
}
}
$data = $criteria->condition ? AdminPost::fetchList($criteria) : null;
return $data;
}
示例13: byParent
public function byParent($idParent)
{
$criteria = new CDbCriteria();
$criteria->addColumnCondition(array('id_parent' => $idParent));
$criteria->order = "sequence ASC";
$this->getDbCriteria()->mergeWith($criteria);
return $this;
}
示例14: clearContacts
/**
* [clearContacts description]
* @return [type]
*/
public function clearContacts()
{
$criteria = new CDbCriteria();
$criteria->addColumnCondition([$this->relationAttribute => $this->owner->id]);
$numberOfContacts = (int) Yii::app()->db->getCommandBuilder()->createCountCommand("{{{$this->relationTable}}}", $criteria)->queryScalar();
$rowsAffected = Yii::app()->db->createCommand()->delete("{{{$this->relationTable}}}", "{$this->relationAttribute} = :owner", [':owner' => $this->owner->id]);
return $numberOfContacts === $rowsAffected;
}
示例15: byInstance
public function byInstance(DaActiveRecord $model)
{
$criteria = new CDbCriteria();
$criteria->addColumnCondition(array('id_photogallery_object' => $model->getIdObject(), 'id_photogallery_instance' => $model->getPrimaryKey()));
$criteria->order = "sequence ASC";
$this->getDbCriteria()->mergeWith($criteria);
return $this;
}