示例#1
0
 /**
  * Set a new condition on property given id or throws an exception if property doesn't exist
  *  
  * @param string $propertyName
  * @param return t41\Backend\Condition
  * @throws t41\Backend\Exception
  */
 public function having($propertyName, $mode = Condition::MODE_AND)
 {
     // reset $_max & populated
     $this->_max = null;
     $this->setParameter('populated', false);
     if (in_array($propertyName, array(Condition::MODE_AND, Condition::MODE_OR))) {
         return $this->setConditionCombo($propertyName);
     }
     // condition on the identifier part of the uri
     if ($propertyName == ObjectUri::IDENTIFIER) {
         return $this->setCondition(new Property\IdentifierProperty(ObjectUri::IDENTIFIER, null, null, $mode));
     } else {
         if (strstr($propertyName, '.') !== false) {
             // deal with recursive properties
             $parts = explode('.', $propertyName);
             $condition = $this->setCondition($this->_do->getProperty($parts[0]));
             foreach (array_slice($parts, 1) as $property) {
                 $condition = $condition->having($property);
             }
             return $condition;
         } else {
             if (($property = $this->_do->getRecursiveProperty($propertyName)) !== false) {
                 return $this->setCondition($property, null, null, $mode);
             }
         }
     }
     throw new Backend\Exception(array("CONDITION_UNKNOWN_PROPERTY", $propertyName));
 }