当前位置: 首页>>代码示例>>PHP>>正文


PHP CDbCriteria::addCondition方法代码示例

本文整理汇总了PHP中CDbCriteria::addCondition方法的典型用法代码示例。如果您正苦于以下问题:PHP CDbCriteria::addCondition方法的具体用法?PHP CDbCriteria::addCondition怎么用?PHP CDbCriteria::addCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDbCriteria的用法示例。


在下文中一共展示了CDbCriteria::addCondition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionIndex

 /**
  * 生成首页
  *
  */
 public function actionIndex()
 {
     //print_r(Yii::app()->user->getState('username'));
     //先获取当前是否有页码信息
     $pages['pageNum'] = Yii::app()->getRequest()->getParam("pageNum", 1);
     //当前页
     $pages['countPage'] = Yii::app()->getRequest()->getParam("countPage", 0);
     //总共多少记录
     $pages['numPerPage'] = Yii::app()->getRequest()->getParam("numPerPage", 50);
     //每页多少条数据
     $pages['tmstart'] = Yii::app()->getRequest()->getParam("tmstart", date('Ym'));
     //开始月份
     $pages['tmstop'] = Yii::app()->getRequest()->getParam("tmstop", date('Ym'));
     //结束月份
     $pages['srh_service'] = Yii::app()->getRequest()->getParam("srh_service", "");
     //按餐厅名称查询
     $criteria = new CDbCriteria();
     !empty($pages['srh_service']) && $criteria->addCondition('type=' . $pages['srh_service']);
     $criteria->addCondition('`month`>=' . $pages['tmstart']);
     $criteria->addCondition('`month`<=' . $pages['tmstop']);
     $pages['countPage'] = AppBsMoney::model()->count($criteria);
     $criteria->limit = $pages['numPerPage'];
     $criteria->offset = $pages['numPerPage'] * ($pages['pageNum'] - 1);
     $allList = AppBsMoney::model()->findAll($criteria);
     $this->renderPartial('index', array('models' => $allList, 'pages' => $pages), false, true);
 }
开发者ID:a707937337,项目名称:bscy,代码行数:30,代码来源:AdminMoneyController.php

示例2: querydealer

 public static function querydealer()
 {
     $cri = new CDbCriteria();
     $cri->addCondition('Identity=2');
     $cri->addCondition("IsBlack='0'");
     $cri->addCondition("IsFreeze='0'");
     $cri->addCondition("Status='1'");
     //获得联盟id
     $organID = Yii::app()->user->getOrganID();
     $unionid = MallService::getUnioninfo($organID);
     $unionid = $unionid ? $unionid : '-1';
     //联盟商品
     $dids = MallService::getUnionOrgan(array('UnionID' => $unionid, 'type' => 2));
     $cri->addCondition('ID in (' . $dids . ')');
     $cri->order = 'Sort ASC';
     $dealer = Organ::model()->findAll($cri);
     $deal_info = array();
     if ($dealer) {
         foreach ($dealer as $key => $val) {
             //将机构图片换成LOGO  修改时间2014-09-03   修改人:邓家文
             //$img=JpdOrganPhoto::model()->find('OrganID=:organ',array(':organ'=>$val['ID']));
             $deal_info[$key]['ID'] = $val['ID'];
             $deal_info[$key]['OrganName'] = $val['OrganName'];
             $deal_info[$key]['Phone'] = $val['Phone'];
             if (!isset($val['Logo']) && empty($val['Logo'])) {
                 $val['Logo'] = 'common/default-goods.png';
             }
             $deal_info[$key]['imgpath'] = $val['Logo'];
         }
     }
     return $deal_info;
 }
开发者ID:zwq,项目名称:unpei,代码行数:32,代码来源:DefaultService.php

示例3: actionIndex

 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     //根据分类查找场地信息
     $city = Yii::app()->request->getParam('city');
     $food = Yii::app()->request->getParam('food');
     $sex = Yii::app()->request->getParam('sex');
     if (!empty($city)) {
         $criteria->addCondition("city = '{$city}'");
     }
     if (!empty($food)) {
         $criteria->addCondition("food = '{$food}'");
     }
     if (!empty($sex)) {
         $criteria->addCondition("sex = '{$sex}'");
     }
     $criteria->addCondition('status = 1');
     //分页类
     $criteria->order = 'id ASC';
     $count = Place::model()->count($criteria);
     //count() 函数计算数组中的单元数目或对象中的属性个数。
     $pager = new CPagination($count);
     $pager->pageSize = 5;
     //每页显示的行数
     $pager->applyLimit($criteria);
     $places = Place::model()->findAll($criteria);
     //查询所有的数据
     $this->render('index', array('places' => $places, 'city' => $city, 'food' => $food, 'sex' => $sex, 'pager' => $pager));
 }
开发者ID:tecshuttle,项目名称:51qsk,代码行数:29,代码来源:PlaceController.php

示例4: actionGetimg

 public function actionGetimg()
 {
     if (isset($_POST['data'])) {
         $data = $_POST['data'];
         $model = new Image();
         $criteria = new CDbCriteria();
         if ($data[0]) {
             $criteria->addCondition("is_show=1 and pid={$data['0']} and id<{$data['1']}");
         } else {
             $criteria->addCondition("is_show=1 and id<{$data['1']}");
         }
         $criteria->order = 'id desc';
         $criteria->limit = 6;
         $imgs = $model->findAll($criteria);
         if (!$imgs) {
             echo 0;
             exit;
         }
         $html = array();
         if ($imgs) {
             foreach ($imgs as $one) {
                 $html[] = "<div class='item'><div class='animate-box bounceIn animated'>\r\n\t\t\t\t\t<a href='javascript:;' class='image-popup fh5co-board-img' title='{$one->title}'><img src='http://7xssk6.com2.z0.glb.clouddn.com/{$one->img}' alt='s-nice'></a>\t\t\t\t\t\t\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class='fh5co-desc'>{$one->des}</div></div>";
             }
             $html[] = "<p style='display:none' id='imgid'>{$one->id}</p>";
         }
         $html = json_encode($html);
         if ($html) {
             echo $html;
             exit;
         } else {
             echo 0;
             exit;
         }
     }
 }
开发者ID:s-nice,项目名称:snece,代码行数:35,代码来源:CommonController.php

示例5: beforeAction

 public function beforeAction($action)
 {
     $criteria = new CDbCriteria();
     $criteria->addCondition('status = 1');
     $criteria->addCondition('created_by = ' . Yii::app()->user->getInfo());
     $this->servicesArray = Services::model()->findAll($criteria);
     $arrayForSettings = array();
     $Settings = Settings::model()->findAll();
     foreach ($Settings as $key => $val) {
         $arrayForSettings[$val->setting_name] = $val->setting_value;
     }
     self::$settings = $arrayForSettings;
     $this->pageTitle = Yii::app()->name;
     $this->pageName = 'Account';
     $this->pageClass = 'blue';
     Yii::app()->session['securityCheck'] = md5(ip2long(Yii::app()->request->userHostAddress) + date("Y"));
     /* @var $cs CClientScript */
     $cs = Yii::app()->clientScript;
     // register jQuery script
     $cs->registerPackage('jquery');
     // register bootstrap script
     $cs->registerPackage('bootstrap');
     // If application is using a theme, replace default layout controller variable that start with '//layouts/' with a theme link
     if (empty(Yii::app()->theme->name) == false && isset($this->layout) == true && strpos($this->layout, '//layouts/') === 0) {
         // Replace path with slash by dot.
         $sThemeLayout = 'webroot.themes.' . Yii::app()->theme->name . '.views.layouts.' . str_replace('/', '.', substr($this->layout, 10));
         // If theme override given layout, get it from theme
         if ($this->getLayoutFile($sThemeLayout) !== false) {
             $this->layout = $sThemeLayout;
         }
     }
     return true;
 }
开发者ID:VanyaAvchyan,项目名称:Pol,代码行数:33,代码来源:Controller.php

示例6: getBlacks

 /**
  *      这个是得到某人的黑名单
  * * @param $userId
  * @return array
  */
 public function getBlacks($userId)
 {
     $criteria = new CDbCriteria();
     $criteria->addCondition('priUserId=' . $userId);
     $criteria->addCondition('type=0');
     return $this->getArray($criteria);
 }
开发者ID:tiger2soft,项目名称:travelman,代码行数:12,代码来源:RelationComponent.php

示例7: actionAll

 public function actionAll()
 {
     $model = Notify::model();
     $user_id = Yii::app()->user->id;
     $criteria = new CDbCriteria();
     $criteria->with = ['status' => ['select' => ['status.id', 'status.notify_id', 'status.user_id', 'status.read_status', 'IF(status.date_showed, status.date_showed, "' . date('c') . '") as date_showed'], 'on' => 'status.user_id = :user_id']];
     $criteria->params = [':user_id' => $user_id, ':all_users' => Notify::All_USERS, ':type' => Notify::TYPE_DEFAULT, ':today' => date('c'), ':user_date_create' => $model->getUserDateCreate($user_id)];
     $criteria->addCondition('t.user_id=:user_id OR t.user_id=:all_users');
     if ($model->isGroupSupport() && $model->getUserGroups($user_id)) {
         $criteria->addInCondition('t.group_id', $model->getUserGroups($user_id), 'OR');
     }
     $criteria->addCondition('(t.date_create >= :user_date_create AND t.date_show<=:today) AND  (IF(date_end, :today <= date_end, 1) OR status.user_id IS NOT NULL)');
     $criteria->addCondition('t.type = :type');
     $criteria->order = 'date_showed desc, t.date_show desc';
     $count = Notify::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = Yii::app()->notify->numberDisplayInAll;
     $pages->applyLimit($criteria);
     $notifications = Notify::model()->findAll($criteria);
     $ids = array_keys(array_filter(CHtml::listData($notifications, 'id', 'status.read_status'), function ($var) {
         return $var == 0;
     }));
     if ($ids) {
         Notify::changeReadStatusByIds($ids, $user_id, Notify::READ);
         $notifications = Notify::model()->findAll($criteria);
     }
     $this->render('all', ['notifications' => $notifications, 'pages' => $pages]);
 }
开发者ID:bookin,项目名称:yii-notification-center,代码行数:28,代码来源:NotifyController.php

示例8: actionSearch

 /**
  * Provides basic searching functionality
  * @param int $id   The search pagination id
  */
 public function actionSearch($id = 1)
 {
     $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => Yii::t('ciims.controllers.Site', 'Search'))));
     $this->layout = '//layouts/default';
     $data = array();
     $pages = array();
     $itemCount = 0;
     $pageSize = Cii::getConfig('searchPaginationSize', 10);
     if (Cii::get($_GET, 'q', false)) {
         $criteria = new CDbCriteria();
         $criteria->addCondition('status = 1')->addCondition('published <= UTC_TIMESTAMP()');
         if (strpos($_GET['q'], 'user_id') !== false) {
             $criteria->addCondition('author_id = :author_id')->addCondition("vid=(SELECT MAX(vid) FROM content AS v WHERE v.id=t.id)");
             $criteria->params = array(':author_id' => str_replace('user_id:', '', Cii::get($_GET, 'q', 0)));
         } else {
             $param = Cii::get($_GET, 'q', 0);
             $criteria->addCondition("vid=(SELECT MAX(vid) FROM content AS v WHERE v.id=t.id) AND ((t.content LIKE :param) OR (t.title LIKE :param2))");
             $criteria->params = array(':param' => '%' . $param . '%', ':param2' => '%' . $param . '%');
         }
         $criteria->addCondition('password = ""');
         $criteria->limit = $pageSize;
         $criteria->order = 'id DESC';
         $itemCount = Content::model()->count($criteria);
         $pages = new CPagination($itemCount);
         $pages->pageSize = $pageSize;
         $criteria->offset = $criteria->limit * $pages->getCurrentPage();
         $data = Content::model()->findAll($criteria);
         $pages->applyLimit($criteria);
     }
     $this->render('search', array('url' => 'search', 'id' => $id, 'data' => $data, 'itemCount' => $itemCount, 'pages' => $pages));
 }
开发者ID:jbelke,项目名称:CiiMS,代码行数:35,代码来源:SiteController.php

示例9: actionGetstandardparamlists

 public function actionGetstandardparamlists()
 {
     $organID = Commonmodel::getOrganID();
     $criteria = new CDbCriteria();
     $criteria->addCondition('organID=' . $organID);
     $criteria->addCondition('mark="U" and ISdelete="N"');
     $criteria->group = 'standard_id';
     //        //查询数据总数
     //        $sql='SELECT count(distinct standard_id) as count FROM `tbl_make_goods_template` where organID='.$organID.' and mark="U" and ISdelete="N"';
     //        $count=Yii::app()->db->createCommand($sql)->queryAll();
     //        $total=$count[0]['count'];sss
     $count = MakeGoodsTemplate::model()->count($criteria);
     $criteria->order = 'id desc';
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = isset($_GET['rows']) ? intval($_GET['rows']) : 10;
     $pages->applyLimit($criteria);
     $datas = MakeGoodsTemplate::model()->findAll($criteria);
     $res = array();
     foreach ($datas as $key => $data) {
         //根据标准名称id查询标准名称
         $res[$key]['id'] = $data['standard_id'];
         $standard = Gcategory::model()->findByPk($data['standard_id']);
         $res[$key]['name'] = $standard['name'];
         $res[$key]['createtime'] = date('Y-m-d H:i:s', $data['createtime']);
         //标准名称参数对应的商品数量
         $sql = 'select count(b.standard_id) from tbl_make_goods a,tbl_make_goods_version b where a.ISdelete=0 and ' . 'a.NewVersion=b.version_name and a.id=b.goods_id and b.standard_id=' . $data['standard_id'] . ' and b.organID=' . $organID;
         $result = Yii::app()->db->createCommand($sql)->queryRow();
         $res[$key]['count'] = $result['count(b.standard_id)'];
     }
     echo json_encode(array('total' => $count, 'rows' => $res));
 }
开发者ID:zwq,项目名称:unpei,代码行数:32,代码来源:StandardparamsController.php

示例10: 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();
     if (isset($_GET["Audit"])) {
         $dH = new DateTimeHelper();
         $dtFrom = $dH->getDateTimeFromUI($_GET["Audit"]["dateTimeFrom"]);
         $dtTo = $dH->getDateTimeFromUI($_GET["Audit"]["dateTimeTo"]);
         if ($desde !== false) {
             $criteria->addCondition('date_time >= ' . $dtFrom->getTimestamp());
         } else {
             $criteria->addCondition('date_time >= ' . $dH->getDefaultStartRangeFilter("")->getTimestamp());
         }
         if ($hasta !== false) {
             $criteria->addCondition('date_time <= ' . $dtTo->getTimestamp());
         } else {
             $criteria->addCondition('date_time <= ' . $dH->getDefaultEndRangeFilter("audit")->getTimestamp());
         }
     }
     $criteria->compare('object', $this->object, true);
     $criteria->compare('operation', $this->operation, true);
     $criteria->compare('description', $this->description, true);
     $criteria->compare('user', $this->user, true);
     return new CActiveDataProvider($this, array('criteria' => $criteria));
 }
开发者ID:pelo8888,项目名称:php-angular-yii,代码行数:37,代码来源:Audit.php

示例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();
     if (Yii::app()->session['group_id'] == 4) {
         $criteria->addCondition('user_group_id=2');
     }
     $criteria->addCondition('status=1');
     $criteria->compare('id', $this->id);
     $criteria->compare('username', $this->username, true);
     $criteria->compare('password', $this->password, true);
     $criteria->compare('fullname', $this->fullname, true);
     $criteria->compare('address', $this->address, true);
     $criteria->compare('email', $this->email, true);
     $criteria->compare('region', $this->region, true);
     $criteria->compare('phone', $this->phone, true);
     $criteria->compare('company', $this->company, true);
     $criteria->compare('avatar', $this->avatar, true);
     $criteria->compare('user_group_id', $this->user_group_id);
     $criteria->compare('created_date', $this->created_date);
     $criteria->compare('status', $this->status);
     $criteria->compare('parent_id', $this->parent_id);
     $criteria->compare('sex', $this->sex);
     $criteria->compare('date_birth', $this->date_birth, true);
     return new CActiveDataProvider($this, array('criteria' => $criteria));
 }
开发者ID:nguyendvphp,项目名称:onlinetraining,代码行数:38,代码来源:WUser.php

示例12: hasConsentForProcedure

 /**
  * checks if there is a consent form for the given episode and the given procedure and eye.
  *
  * @param Episode   $episode
  * @param Procedure $procedure
  * @param string    $side      - left, right or both
  *
  * @throws Exception
  *
  * @return bool
  */
 public function hasConsentForProcedure($episode, $procedure, $side)
 {
     if ($episode) {
         $required_eye = Eye::BOTH;
         if (!in_array($side, array('left', 'right', 'both'))) {
             throw new Exception('unrecognised side value ' . $side);
         }
         $event_type = $this->getEventType();
         $criteria = new CDbCriteria();
         $criteria->addCondition('event.event_type_id = :eventtype_id');
         $criteria->addCondition('event.episode_id = :episode_id');
         $criteria->addCondition('procedures.id = :proc_id OR additional_procedures.id = :proc_id');
         $criteria->params = array(':eventtype_id' => $event_type->id, ':episode_id' => $episode->id, ':proc_id' => $procedure->id);
         $criteria->order = 't.created_date desc';
         $eye_ids = array('eye_id' => Eye::BOTH);
         if ($side == 'left') {
             $eye_ids[] = Eye::LEFT;
             $required_eye = Eye::LEFT;
         } elseif ($side == 'right') {
             $eye_ids[] = Eye::RIGHT;
             $required_eye = Eye::RIGHT;
         }
         $criteria->addInCondition('t.eye_id', $eye_ids);
         foreach (Element_OphTrConsent_Procedure::model()->with('event', 'procedures', 'additional_procedures')->findAll($criteria) as $consent_proc) {
             if ($consent_proc->eye_id == Eye::BOTH || $consent_proc->eye_id == $required_eye) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:openeyes,项目名称:openeyes,代码行数:42,代码来源:OphTrConsent_API.php

示例13: search

 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search($params)
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new CDbCriteria();
     $criteria->compare('id', $this->id, true);
     $criteria->compare('currency_id', $this->currency_id, true);
     $criteria->compare('date', $this->date, true);
     $criteria->compare('value', $this->value, true);
     if (!empty($this->from) && empty($this->to)) {
         $this->from = date("Y-m-d", CDateTimeParser::parse($this->from, Yii::$app->locale->getDateFormat('yiishort')));
         $criteria->addCondition("date>=:date_from");
         $criteria->params[':date_from'] = $this->from;
     } elseif (!empty($this->to) && empty($this->from)) {
         $this->to = date("Y-m-d", CDateTimeParser::parse($this->to, Yii::$app->locale->getDateFormat('yiishort')));
         $criteria->addCondition("date>=:date_to");
         $criteria->params[':date_to'] = $this->to;
     } elseif (!empty($this->to) && !empty($this->from)) {
         $this->from = date("Y-m-d", CDateTimeParser::parse($this->from, Yii::$app->locale->getDateFormat('yiishort')));
         $this->to = date("Y-m-d", CDateTimeParser::parse($this->to, Yii::$app->locale->getDateFormat('yiishort')));
         $criteria->addCondition("date>=:date_from");
         $criteria->addCondition("date<=:date_to");
         $criteria->params[':date_from'] = $this->from;
         $criteria->params[':date_to'] = $this->to;
     }
     $sort = new CSort();
     $sort->defaultOrder = 'date DESC';
     return new CActiveDataProvider($this, array('criteria' => $criteria, 'sort' => $sort));
 }
开发者ID:chaimvaid,项目名称:linet3,代码行数:33,代码来源:Currates.php

示例14: ActionOperationLogList

 /**
  * 操作日志列表
  */
 public function ActionOperationLogList()
 {
     $criteria = new CDbCriteria();
     // 判断查询类型 (分页查询 / 条件查询)
     $searchType = Yii::app()->request->getParam('searchType');
     if ($searchType === 'page') {
         $search_condition = unserialize(base64_decode(Yii::app()->request->getParam('search_condition')));
         // 对分布传来的数据进行还原
     } else {
         // 如有搜索条件 则获取条件并过滤条件数组中的空格与空值
         if (!empty($_POST['search'])) {
             foreach ($_POST['search'] as $key => $val) {
                 $search_condition[$key] = trim($val);
             }
             $search_condition = array_filter($search_condition);
         } else {
             $search_condition = '';
         }
     }
     // 增加搜索条件 [S]
     // 搜索条件中包含时间 则添加时间查询条件
     if (!empty($search_condition['start_time']) || !empty($search_condition['end_time'])) {
         // 如起始时间与结束时间一致 则查询同一个时间点的数据
         if (!empty($search_condition['start_time']) && !empty($search_condition['end_time']) && $search_condition['start_time'] == $search_condition['end_time']) {
             $criteria->addSearchCondition('CreationDate', $search_condition['start_time']);
         } else {
             // 1.只按起始时间查询 2.只按结束时间查询 3.按起始+结束时间段查询
             if (!empty($search_condition['start_time']) && empty($search_condition['end_time'])) {
                 $criteria->addCondition('CreationDate >= :start_time');
                 $criteria->params[':start_time'] = $search_condition['start_time'] . ' 23:59:59';
             } else {
                 if (empty($search_condition['start_time']) && !empty($search_condition['end_time'])) {
                     $criteria->addCondition('CreationDate <= :end_time');
                     $criteria->params[':end_time'] = $search_condition['end_time'] . ' 23:59:59';
                 } else {
                     $criteria->addBetweenCondition('CreationDate', $search_condition['start_time'], $search_condition['end_time']);
                 }
             }
         }
     }
     // 搜索条件中包含真实姓名 则添加关联查询及条件
     if (!empty($search_condition['real_name'])) {
         $criteria->with = array('account' => array('joinType' => 'INNER JOIN', 'condition' => 'account.RealName="' . $search_condition['real_name'] . '"'));
     }
     //增加搜索条件 [E]
     // 分页配置
     $criteria->order = 't.ID DESC';
     $count = OperationLog::model()->count($criteria);
     $pager = new CPagination($count);
     if (!empty($search_condition)) {
         //判断是否存在搜索条件,并对搜索条件进行数据处理(便于url传输)
         $pager->params = array('search_condition' => base64_encode(serialize($search_condition)), 'searchType' => 'page');
     }
     $pager->pageSize = 20;
     $pager->applyLimit($criteria);
     // 获取日志列表
     $operation_log_list = OperationLog::model()->findAll($criteria);
     // 跳转至用户操作日志页面
     $this->render('list_operation_log', array('operation_log_list' => $operation_log_list, 'pages' => $pager, 'search_condition' => $search_condition));
 }
开发者ID:lovecheng,项目名称:brs-demo2,代码行数:63,代码来源:OperationLogController.php

示例15: numero

 public static function numero($modelito, $campo, $aliascampo, $anchocampo, $campocriterio = NULL, $campocriterio2 = null, $prefijo = null)
 {
     //$this->numkardex=$gg->numero($this,'correlativ','maximovalor',12,'codmov');
     //$this->numero=$gg->numero($this,'correlativ','maximovalor',7,'codocu');
     //$campo : es el campo en el cual se va a sacar el valor maximo de la tabla segun u criterio o 2 segun se hayan
     //         definido en los campos $campocriterio y $campocriterio2
     //$campocriterio: El criterio WHERE que filtra a los valores de $campo
     //$campocriterio2: El criterio AND  que filtra a los valores de $campo y where de $criterio
     $criteria = new CDbCriteria();
     $criteria->select = 'max(' . $campo . ') AS ' . $aliascampo . '';
     if (!is_null($campocriterio)) {
         $criteria->addCondition(" " . $campocriterio . "='" . $modelito->{$campocriterio} . "' ");
     }
     if (!is_null($campocriterio2)) {
         $criteria->addCondition(" " . $campocriterio2 . "='" . $modelito->{$campocriterio2} . "' ");
     }
     $row = $modelito->model()->find($criteria);
     ///el resultado de efectuar el maximo valor de la tabla
     $somevariable = is_null($row) ? 1 : $row[$aliascampo] + 1;
     //a esto se le agrega uno mas
     $modelito->{$campo} = gettype($modelito->{$campo}) == 'string' ? $somevariable . '' : $somevariable;
     if (!is_null($campocriterio)) {
         return $modelito->{$campocriterio} . str_pad($somevariable . '', $anchocampo, "0", STR_PAD_LEFT);
     } else {
         return str_pad($somevariable, $anchocampo, "0", STR_PAD_LEFT);
     }
     Yii::app()->end();
     //return "0000000000".$somevariable;
 }
开发者ID:hipogea,项目名称:zega,代码行数:29,代码来源:Numeromaximo.php


注:本文中的CDbCriteria::addCondition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。