/** * 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))); } }