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


PHP CDbCriteria::toArray方法代码示例

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


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

示例1: search

 public function search()
 {
     $criteria = new CDbCriteria();
     if ($this->startDate) {
         $criteria->compare('cli_created', '>=' . Date::formatDate('Y-m-d', $this->startDate));
     }
     if ($this->endDate) {
         $criteria->compare('cli_created', '<=' . Date::formatDate('Y-m-d', $this->endDate));
     }
     $data = Yii::app()->db->createCommand()->from('client');
     switch ($this->granulation) {
         case self::GRANULARITY_WEEK:
             $data = $data->select('YEAR(cli_created) year, WEEK(cli_created) period, COUNT(*) count');
             $data = $data->group('YEAR(cli_created), WEEK(cli_created)');
             break;
         case self::GRANULARITY_MONTH:
             $data = $data->select('YEAR(cli_created) year, MONTH(cli_created) period, COUNT(*) count');
             $data = $data->group('YEAR(cli_created), MONTH(cli_created)');
             break;
         case self::GRANULARITY_DAY:
             $data = $data->select('YEAR(cli_created) year, DAYOFYEAR(cli_created) period, COUNT(*) count');
             $data = $data->group('YEAR(cli_created), DAYOFYEAR(cli_created)');
             break;
         default:
             $data = $data->select('YEAR(cli_created) year, WEEK(cli_created) period, COUNT(*) count');
             $data = $data->group('YEAR(cli_created), WEEK(cli_created)');
             break;
     }
     if ($criteria->toArray()['condition']) {
         $data->where($criteria->toArray()['condition']);
         $data->params = $criteria->params;
     }
     $data = $data->queryAll();
     return $data;
 }
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:35,代码来源:RegisteredStatistics.php

示例2: 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(CDbCriteria $criteria = null)
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     if ($criteria) {
         $criteria = new CDbCriteria($criteria->toArray());
     } else {
         $criteria = new CDbCriteria();
     }
     $criteria->compare('id', $this->id, true);
     $criteria->compare('page', $this->page, true);
     $criteria->compare('viewCount', $this->viewCount, true);
     $criteria->compare('lastAccessed', $this->lastAccessed, true);
     $criteria->compare('lastViewId', $this->lastViewId, true);
     return new CActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => array('pageSize' => 37)));
 }
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:20,代码来源:PageViewStatistic.php

示例3: actionIndex

    public function actionIndex($id){
        $this->initialize($id);
        $editMode = $this->checkEditMode($id, Yii::app()->user->getId());

        $lecture = Lecture::model()->findByPk($id);

        $criteria = new CDbCriteria();
        $criteria->addCondition('id_lecture='.$id);

        $dataProvider = new CActiveDataProvider('LectureElement');
        $dataProvider->criteria = $criteria;
        $criteria->order = 'block_order ASC';
        $dataProvider->setPagination(array(
                'pageSize' => '200',
            )
        );

        $owners = [];

        $criteria1 = new CDbCriteria();
        $criteria1->alias='teacher_module';
        $criteria1->select = 'idTeacher';
        $criteria1->addCondition('idModule='.$lecture->idModule);
        $criteria1->toArray();
        $temp = TeacherModule::model()->findAll($criteria1); //info about owners
        for($i = 0; $i < count($temp);$i++){
            array_push($owners, $temp[$i]->idTeacher);
        }
        $teachers = Teacher::model()->findAllByPk($owners);

        $countBlocks = LectureElement::model()->count('id_lecture = :id', array(':id' => $id));

        $this->render('index', array(
            'dataProvider' => $dataProvider,
            'lecture' => $lecture,
            'editMode' => $editMode,
            'countBlocks' => $countBlocks,
            'teachers' => $teachers,
        ));
    }
开发者ID:nico13051995,项目名称:IntITA,代码行数:40,代码来源:LessonController.php

示例4: modifySearchCriteria

 /**
  * Modify passed criteria by replacing conditions on base attributes with conditions on translations.
  * Allow to make search on model translated values.
  * @param CDbCriteria $event
  */
 public function modifySearchCriteria(CDbCriteria $criteria)
 {
     $owner = $this->getOwner();
     $criteria_array = $criteria->toArray();
     foreach ($this->localizedAttributes as $attribute) {
         if (!empty($owner->{$attribute})) {
             $criteria_array['condition'] = str_replace($attribute . ' ', $this->localizedPrefix . $attribute . ' ', $criteria_array['condition']);
         }
     }
     $criteria_array['together'] = true;
     $criteria = new CDbCriteria($criteria_array);
     return $criteria;
 }
开发者ID:DarkAiR,项目名称:test,代码行数:18,代码来源:MultilingualBehavior.php

示例5: defaultScope

 public function defaultScope()
 {
     $alias = $this->getTableAlias(true, false);
     $criteria = new CDbCriteria(array('condition' => $alias . '.deleted=0 AND ' . $alias . '.visible=1', 'order' => $alias . '.retail_price DESC'));
     //Если отключена возможность заявок на товар под заказ
     if (!Yii::app()->daShop->makeOfferByOrder) {
         $criteria->addCondition($alias . '.remain > 0', 'AND');
     }
     return $criteria->toArray();
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:10,代码来源:Product.php

示例6: testToArray

 public function testToArray()
 {
     $keys = array('select', 'condition', 'params', 'limit', 'offset', 'order', 'group', 'join', 'having', 'distinct', 'scopes', 'with', 'alias', 'index', 'together');
     $criteria = new CDbCriteria();
     $this->assertEquals($keys, array_keys($criteria->toArray()));
 }
开发者ID:super-d2,项目名称:codeigniter_demo,代码行数:6,代码来源:CDbCriteriaTest.php

示例7: getModuleTitles

 public static function getModuleTitles(){
     $criteria =new CDbCriteria();
     $criteria->select = array('module_ID', 'module_name');
     $criteria->toArray();
     $count = Module::model()->count();
     $titles = Module::model()->findAll($criteria);
     $result = [];
     for ($i = 0; $i < $count; $i++) {
         $result[$titles[$i]["module_ID"]] = $titles[$i]["module_name"];
     }
     return $result;
 }
开发者ID:nico13051995,项目名称:IntITA,代码行数:12,代码来源:AccessHelper.php

示例8: defaultScope

 public function defaultScope()
 {
     $alias = $this->getTableAlias(true, false);
     $criteria = new CDbCriteria(array('order' => $alias . '.id_reference_element'));
     return $criteria->toArray();
 }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:6,代码来源:ReferenceElement.php

示例9: getRoleTitlesList

    public static function getRoleTitlesList(){
        $criteria = new CDbCriteria();
        $criteria->select = 'id, title_ua';
        $criteria->distinct = true;
        $criteria->toArray();

        $result = '';
        $titles = Roles::model()->findAll($criteria);
        for($i = 0; $i < count($titles); $i++){
            $result[$i][$titles[$i]['id']] = $titles[$i]['title_ua'];
        }
        return $result;
    }
开发者ID:nico13051995,项目名称:IntITA,代码行数:13,代码来源:TeacherHelper.php

示例10: getVentas

 public function getVentas($desde, $hasta, $criterio = false)
 {
     //if ($desde and $hasta
     //and preg_match("(\d{4}-\d{2}-\d{2})",$desde)==1
     //and preg_match("(\d{4}-\d{2}-\d{2})",$hasta)==1){
     if ($criterio) {
         if (is_array($criterio)) {
             $criteria = new CDbCriteria($criterio);
             $criterio = $criteria->toArray();
         }
         if (is_object($criterio)) {
             $criterio = $criterio->toArray();
         }
         if (isset($criterio['select']) and is_array($criterio['select'])) {
             $criterio['select'] = implode(',', $criterio['campos']);
         }
         if (isset($criterio['condition']) and is_array($criterio['condition'])) {
             $criterio['condition'] = implode(',', $criterio['condicion']);
         }
         if (isset($criterio['group']) and is_array($criterio['group'])) {
             $criterio['group'] = implode(',', $criterio['group']);
         }
         if (isset($criterio['order']) and is_array($criterio['order'])) {
             $criterio['order'] = implode(',', $criterio['order']);
         }
     } else {
         $criterio = array('select' => '', 'condition' => '', 'order' => 'PuntosventaNom', 'group' => 'PuntosventaNom');
     }
     $criterio['select'] = strlen($criterio['select']) > 1 ? ',' . $criterio['select'] : '';
     $criterio['condition'] = strlen($criterio['condition']) > 0 ? $criterio['condition'] : '1';
     $criterio['order'] = strlen($criterio['order']) > 0 ? $criterio['order'] : 'PuntosventaNom';
     $criterio['group'] = strlen($criterio['group']) > 0 ? $criterio['group'] : 'PuntosventaNom';
     $query = sprintf("SELECT t.PuntosventaId as id,\n\t\t\t\t\tPuntosventaNom,\n\t\t\t\t\tSUM(t1.VentasCosBol+t1.VentasCarSer) as importe,\n\t\t\t\t\tCOUNT(*) as boletos,\n\t\t\t\t\tCOUNT(distinct t.VentasId) as ventas,\n\t\t\t\t\tMAX(VentasFecHor) as ultimo\n\t\t\t\t\t%s\n\t\t\t\t\tFROM ventas AS t\n\t\t\t\t\tINNER JOIN ventaslevel1 as t1 ON t.VentasId=t1.VentasId \n\t\t\t\t\tINNER JOIN puntosventa  as t2 ON t2.PuntosventaId=t.PuntosVentaId\n\t\t\t\t\tWHERE DATE(t.VentasFecHor) BETWEEN '{$desde}' AND '{$hasta}'\n\t\t\t\t\tAND VentasCosBol>10 \n\t\t\t\t\tAND t.VentasSta NOT LIKE 'CANCELADO' AND t1.VentasSta NOT LIKE 'CANCELADO'\n\t\t\t\t\tAND  %s \n\t\t\t\t\tGROUP BY %s ORDER BY %s ", $criterio['select'], $criterio['condition'], $criterio['group'], $criterio['order']);
     return new CSqlDataProvider($query, array('pagination' => false));
     /*$rawData=Yii::app()->db->createCommand(sprintf("SELECT t.PuntosventaId as id,
     		PuntosventaNom,
     		SUM(t1.VentasCosBol+t1.VentasCarSer) as importe,
     		COUNT(*) as boletos,
     		COUNT(distinct t.VentasId) as ventas,
     		MAX(VentasFecHor) as ultimo
     		%s
     		FROM ventas AS t
     		INNER JOIN ventaslevel1 as t1 ON t.VentasId=t1.VentasId 
     		INNER JOIN puntosventa  as t2 ON t2.PuntosventaId=t.PuntosVentaId
     		WHERE DATE(t.VentasFecHor) BETWEEN '$desde' AND '$hasta'
     		AND VentasCosBol>10 
     		AND t.VentasSta NOT LIKE 'CANCELADO' AND t1.VentasSta NOT LIKE 'CANCELADO'
     		AND  %s 
     		GROUP BY %s ORDER BY %s ",$criterio['select'],$criterio['condition'],$criterio['group'],$criterio['order']))->queryAll();
              // or using: $rawData=User::model()->findAll();
              return new CArrayDataProvider($rawData, array(
                  'id'=>'id',
                  'sort'=>array(
                      'attributes'=>array(
                           'id','PuntosventaNom','importe'
                      ),
                  ),
                  'pagination'=>false,
              ));*/
 }
开发者ID:cicb,项目名称:tpc,代码行数:60,代码来源:ReportesVentas.php

示例11: actionIndex

	/**
	 * Lists all models.
	 */
	public function actionIndex($idModule)
	{
        $model = Module::model()->findByPk($idModule);
        $owners = [];

        $criteria1 = new CDbCriteria();
        $criteria1->select = 'idTeacher';
        $criteria1->addCondition('idModule='.$idModule);
        $criteria1->toArray();
        $temp = TeacherModule::model()->findAll($criteria1); //info about owners
        for($i = 0; $i < count($temp);$i++){
            array_push($owners, $temp[$i]->idTeacher);
        }
        $teachers = Teacher::model()->findAllByPk($owners);

        $criteria=new CDbCriteria();
        $criteria->addCondition('idModule>0');
        $criteria->addCondition('idModule='.$idModule);

        $dataProvider = new CActiveDataProvider('Lecture', array(
            'criteria' =>$criteria,
            'pagination'=>false,
            'sort'=>array(
                'defaultOrder'=>array(
                    'order'=>CSort::SORT_ASC,
                )
            )
        ));

        $editMode = 0; //init editMode flag
        //find id teacher related to current user id
        if (Yii::app()->user->isGuest){ //if user guest
            $editMode = 0;
        } else {
            if (Teacher::model()->exists('user_id=:user_id', array(':user_id' => Yii::app()->user->getId()))) {
                if ($teacherId = Teacher::model()->findByAttributes(array('user_id' => Yii::app()->user->getId()))->teacher_id) {
                    //check edit mode
                    if (TeacherModule::model()->exists('idTeacher=:teacher AND idModule=:module', array(':teacher' => $teacherId, ':module' => $idModule))){
                        $editMode = 1;
                    } else {
                        $editMode = 0;
                    }
                } else{
                    $editMode = 0;
                }
            } else {
                $editMode = 0;
            }
        }

        $lecturesTitles = Lecture::model()->getLecturesTitles($idModule);

        $this->render('index', array(
            'post' => $model,
            'teachers' => $teachers,
            'editMode' => $editMode,
            'lecturesTitles' => $lecturesTitles,
            'dataProvider' => $dataProvider,
        ));
	}
开发者ID:nico13051995,项目名称:IntITA,代码行数:63,代码来源:ModuleController.php

示例12: getCourses

    public function getCourses(){
//        $modules = TeacherModule::model()->findAllBySql('select idModule from teacher_module where idTeacher = :idTeacher;',array(':idTeacher' => $this->idTeacher));
        $modules =[1,3, 7, 10];
        $criteria = new CDbCriteria();
        $criteria->select = 'course';
        $criteria->distinct = true;
        $criteria->addInCondition('course', $modules);
        $criteria->toArray();
        $courses = Module::model()->findAll($criteria);

        return $courses;
    }
开发者ID:nico13051995,项目名称:IntITA,代码行数:12,代码来源:ProfileController.php

示例13: getCourseTeachers

    public static function getCourseTeachers($modules){
        $criteria = new CDbCriteria();
        $criteria->select =  'idTeacher';
        $criteria->order = 'idTeacher';
        $criteria->addInCondition('idModule', $modules);
        $criteria->distinct = true;
        $criteria->toArray();

        $teachers = TeacherModule::model()->findAll($criteria);
        $result = [];
        for ($i = 0; $i < count($teachers); $i++){
            array_push($result, $teachers[$i]["idTeacher"]);
        }
        return $result;
    }
开发者ID:nico13051995,项目名称:IntITA,代码行数:15,代码来源:TeacherModule.php


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