コード例 #1
0
ファイル: SearchComponent.php プロジェクト: kot-ezhva/ygin
 public static function recreateIndex($idLang = 1, $arrayWithBadObject = array())
 {
     // Удаляем старые данные
     Yii::app()->db->createCommand('DELETE FROM da_search_data WHERE id_lang=:id_lang')->execute(array(':id_lang' => $idLang));
     // По каким свойствам нужно искать
     $ids = Yii::app()->db->createCommand()->selectDistinct('id_object')->from('da_object_parameters')->where('search=1')->queryColumn();
     $searchDataPortion = Yii::app()->getModule('search')->searchDataPortion;
     if (intval($searchDataPortion) < 1) {
         $searchDataPortion = 1000;
     }
     foreach ($ids as $idObject) {
         $obj = DaObject::getById($idObject);
         $model = DaInstance::forObject($obj);
         $startRecord = 0;
         while (true) {
             $data = $model->findAll(array('limit' => $searchDataPortion, 'offset' => $startRecord));
             foreach ($data as $instance) {
                 self::replaceIndex($instance, $idLang);
             }
             if (count($data) == 0 || count($data) < $searchDataPortion) {
                 break;
             }
             $startRecord += $searchDataPortion;
         }
     }
 }
コード例 #2
0
ファイル: DaObject.php プロジェクト: kot-ezhva/ygin
 /**
  * @return DaActiveRecord
  */
 public function getModel($newModel = false)
 {
     if ($this->yii_model != null) {
         $classModel = Yii::import($this->yii_model, true);
         $model = $newModel ? self::newModel($classModel) : self::model($classModel);
         /**
          * @var $model DaActiveRecord
          */
         $model->setObjectInstance($this);
         $model->resetScope();
         return $model;
     }
     return DaInstance::forObject($this);
 }
コード例 #3
0
ファイル: DaInstance.php プロジェクト: kot-ezhva/ygin
 public static function forObject(DaObject $object, $scenario = 'insert')
 {
     $model = new DaInstance($scenario, $object->table_name);
     $model->setObjectInstance($object);
     return $model;
 }