/** * Property set access. * * @param string $propertyName * @param mixed $properyValue * @ignore * * @throws ezcBasePropertyNotFoundException * if the desired property could not be found. * @throws ezcBaseValueException * if $properyValue is not valid for $propertyName. */ public function __set($propertyName, $properyValue) { switch ($propertyName) { case 'relationSource': if (!is_object($properyValue) && $properyValue !== null) { throw new ezcBaseValueException($propertyName, $properyValue, 'Object or null'); } $this->properties[$propertyName] = $properyValue; return; case 'relationSetName': if (!is_string($properyValue) && $properyValue !== null) { throw new ezcBaseValueException($propertyName, $properyValue, 'string or null'); } $this->properties[$propertyName] = $properyValue; return; } parent::__set($propertyName, $properyValue); }
public function testDelegateSuccess() { $q = $this->getMock('ezcQuerySelect', array('reset', 'alias', 'select'), array(), '', false, false); $q->expects($this->once())->method('reset')->will($this->returnValue(23)); $q->expects($this->once())->method('alias')->with('someName', 'someAlias'); $q->expects($this->never())->method('select'); $cn = 'myCustomClassName'; $findQuery = new ezcPersistentFindQuery($q, $cn); $this->assertEquals(23, $findQuery->reset()); $this->assertNull($findQuery->alias('someName', 'someAlias')); }
/** * Sets find query value for many-to-many related objects. * * Manipulates the find $query for objects related to the object defined in * $objectState, defined my the relation $relation. * * @param ezcPersistentFindQuery $query * @param ezcPersistentObjectDefinition $def * @param ezcPersistentManyToManyRelation $relation * @param array $objectState */ private function createComplexRelationFindQuery(ezcPersistentFindQuery $query, ezcPersistentObjectDefinition $def, ezcPersistentManyToManyRelation $relation, array $objectState) { $db = $this->database; $relationTableQuoted = $db->quoteIdentifier($relation->relationTable); // Join with relation table. $query->from($relationTableQuoted); foreach ($relation->columnMap as $map) { $query->where($query->expr->eq($relationTableQuoted . "." . $db->quoteIdentifier($map->relationSourceColumn), $query->bindValue($objectState[$def->columns[$map->sourceColumn]->propertyName], null, $def->columns[$map->sourceColumn]->databaseType)), $query->expr->eq($relationTableQuoted . "." . $db->quoteIdentifier($map->relationDestinationColumn), $db->quoteIdentifier($relation->destinationTable) . "." . $db->quoteIdentifier($map->destinationColumn))); } }
/** * Property set access. * * @param string $propertyName * @param mixed $properyValue * @ignore * * @throws ezcBasePropertyNotFoundException * if the desired property could not be found. * @throws ezcBaseValueException * if $properyValue is not valid for $propertyName. */ public function __set($propertyName, $properyValue) { switch ($propertyName) { case 'isRestricted': case 'relations': throw new ezcBasePropertyPermissionException($propertyName, ezcBasePropertyPermissionException::READ); default: return parent::__set($propertyName, $properyValue); } }