/** * Returns the SQL string for the subselect. * * Example: * <code> * <?php * $subSelect = $q->subSelect(); * $subSelect->select( name )->from( 'table2' ); * $q->select( '*' ) * ->from( 'table1' ) * ->where ( $q->expr->eq( 'name', $subSelect ) ); * $stmt = $q->prepare(); * $stmt->execute(); * ?> * </code> * * @return string */ public function getQuery() { return '( ' . parent::getQuery() . ' )'; }
/** * 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 * 'placeholder1', 'placeholder2' 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); }