public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(ResourceAttributeVersionPeer::ID, $pks, Criteria::IN);
         $objs = ResourceAttributeVersionPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Exemplo n.º 2
0
 public function countResourceAttributeVersions($criteria = null, $distinct = false, $con = null)
 {
     include_once 'plugins/sfPropelVersionableBehaviorPlugin/lib/model/om/BaseResourceAttributeVersionPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     $criteria->add(ResourceAttributeVersionPeer::RESOURCE_VERSION_ID, $this->getId());
     return ResourceAttributeVersionPeer::doCount($criteria, $distinct, $con);
 }
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = ResourceAttributeVersionPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setResourceVersionId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setAttributeName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setAttributeValue($arr[$keys[3]]);
     }
 }
 /**
  * Returns all ResourceVersion instances related to the object, ordered by version asc.
  * 
  * @param      BaseObject   $resource
  * @return     array        List of BaseObject objects
  */
 public function getAllVersions(BaseObject $resource)
 {
     $c = new Criteria();
     $c->add(ResourceVersionPeer::RESOURCE_ID, $resource->getPrimaryKey());
     $c->add(ResourceVersionPeer::RESOURCE_NAME, get_class($resource));
     $c->add(ResourceVersionPeer::NUMBER, null, Criteria::ISNOTNULL);
     $c->addAscendingOrderByColumn(ResourceVersionPeer::NUMBER);
     $c->addJoin(ResourceAttributeVersionPeer::RESOURCE_VERSION_ID, ResourceVersionPeer::ID);
     $attributes = ResourceAttributeVersionPeer::doSelect($c);
     $objects = array();
     $object = null;
     $class = get_class($resource);
     $current_id = null;
     foreach ($attributes as $attribute) {
         if ($attribute->getResourceVersionId() != $current_id) {
             if ($object) {
                 $objects[] = $object;
             }
             $current_id = $attribute->getResourceVersionId();
             $object = new $class();
         }
         $attrib_name = $attribute->getAttributeName();
         $setter = sprintf('set%s', $attrib_name);
         if (!method_exists($resource, $setter)) {
             $msg = sprintf('Impossible to set attribute "%s" on resource "%s"', $attrib_name, get_class($resource));
             throw new Exception($msg);
         }
         $object->{$setter}($attribute->getAttributeValue());
     }
     $objects[] = $object;
     return $objects;
 }