/** * 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 ezcQuery $query * @param ezcPersistentObjectDefinition $def * @param ezcPersistentManyToManyRelation $relation * @param array $objectState */ private function createComplexRelationFindQuery(ezcQuery $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))); } }
/** * Binds the value $value to the specified variable name $placeHolder. * * This method uses ezcQuery::bindParam() from the ezcQuery class in which * the subSelect was called. Info about bound parameters are stored in * the parent ezcQuery object that is stored in the $outer property. * * The parameter $value specifies the value that you want to bind. If * $placeholder is not provided bindValue() will automatically create a * placeholder for you. An automatic placeholder will be of the name * 'ezcValue1', 'ezcValue2' etc. * * Example: * <code> * <?php * $value = 2; * $subSelect = $q->subSelect(); * $subSelect->select( name ) * ->from( 'table2' ) * ->where( $subSelect->expr->in( * 'id', $subSelect->bindValue( $value ) * ) * ); * * $q->select( '*' ) * ->from( 'table1' ) * ->where ( $q->expr->eq( 'name', $subSelect ) ); * * $stmt = $q->prepare(); // the $value is bound to the query. * $value = 4; * $stmt->execute(); // subselect executed with 'id = 2' * ?> * </code> * * @see ezcQuery::bindValue() * * @param mixed $value * @param string $placeHolder the name to bind with. The string must start with a colon ':'. * @return string the placeholder name used. */ public function bindValue($value, $placeHolder = null, $type = PDO::PARAM_STR) { return $this->outerQuery->bindValue($value, $placeHolder, $type); }
/** * Limits the given $query to the subtree starting at $rootLocationId * * @param \ezcQuery $query * @param string $rootLocationId * * @return void */ protected function applySubtreeLimitation(\ezcQuery $query, $rootLocationId) { $query->where($query->expr->like($this->handler->quoteColumn('path_string', 'ezcontentobject_tree'), $query->bindValue('%/' . $rootLocationId . '/%'))); }