/**
  *
  * @param string $model_name
  * @param array  $data   
  * @return Doctrine_Collection 
  */
 public static function createCollection($model_name, $data)
 {
     $collection = new Doctrine_Collection($model_name);
     if (!$collection instanceof Doctrine_Collection) {
         throw new sfException('Trying to hydrate a non-Doctrine_collection object!');
     }
     $collection->fromArray($data);
     return $collection;
 }
 public function getResults()
 {
     if (is_null($this->results)) {
         $this->getQuery()->orderBy($this->sqlOrderColumn . ' ' . $this->sqlOrder);
         $this->results = parent::getResults();
         if ($this->sqlOrder !== $this->listOrder) {
             $obj = new Doctrine_Collection($this->results->getTable(), $this->results->getKeyColumn());
             $obj->fromArray(array_reverse($this->results->toArray(true)));
             $this->results = $obj;
         }
     }
     return $this->results;
 }
 /**
  * @param $dataSetId
  * @param $scenarioId
  * @return Doctrine_Collection
  */
 public function findMissingElementsInDataSet($dataSetId, $scenarioId)
 {
     // Préparation de la requête SQL permettant de récupérer les éléments manquants dans le jeu de données.
     $querySql = '
       SELECT *
       FROM ei_data_set_structure ds
       WHERE ds.ei_scenario_id = ' . $scenarioId . '
       AND id NOT IN (SELECT ei_data_set_structure_id FROM ei_data_line WHERE ei_data_set_id = ' . $dataSetId . ')
       ORDER BY lft;
     ';
     // Récupération de tous les éléments.
     $resultats = Doctrine_Manager::getInstance()->getCurrentConnection()->fetchAll($querySql);
     // Importation.
     $collection = new Doctrine_Collection("EiDataSetStructure");
     $collection->fromArray($resultats);
     return $collection;
 }
Ejemplo n.º 4
0
 /**
  * Load the data from cache
  *
  * @return void
  */
 private function _loadFromCache(Zend_Cache_Core $cache)
 {
     $cacheData = $cache->load($this->_cacheKey);
     $dbData = new Doctrine_Collection($cacheData['tableName']);
     $dbData->fromArray($cacheData['dataArray'], self::SERIALIZATION_DEEP);
     $this->_dbData = $dbData;
 }