コード例 #1
0
ファイル: SDBStatement.php プロジェクト: laiello/flexible-orm
 /**
  * Fetch results into the specified class objects
  *
  * Behaves like ORM_PDOStatement::fetchAllInto().
  *
  * @throws ORMFetchIntoClassNotFoundException for invalid classname
  * @throws ORMFetchIntoException for AmazonSDB errors
  *
  * @param string $className
  *      Object type to fetch into
  * @return ModelCollection
  *      Collection of objects of type $className
  */
 public function fetchAllInto($className)
 {
     if (!class_exists($className)) {
         throw new ORMFetchIntoClassNotFoundException("Unknown class {$className} requested");
     }
     $collection = new ModelCollection();
     if (!$this->_result->isOK()) {
         throw new ORMFetchIntoException($this->_result->errorMessage());
     } elseif (count($this->_result)) {
         foreach ($this->_result as $key => $attributes) {
             $object = new $className();
             $object->id($key);
             $object->setValues($attributes);
             $this->_fetchWith($object);
             $collection[] = $object;
         }
     }
     return $collection;
 }
コード例 #2
0
ファイル: SDBResponse.php プロジェクト: laiello/flexible-orm
 /**
  * Get items from a query and add them to this query
  * 
  * @throws ORMPDOException if SDB response is not OK
  * @param SDBResponse $response 
  */
 private function _setItems(SDBResponse $response)
 {
     if (!$response->isOK()) {
         throw new ORMPDOException($response->errorMessage() . ' - ' . $response->getQuery());
     }
     foreach ($response as $key => $item) {
         $this->_items[$key] = $item;
     }
 }