PHP Class eZ\Publish\Core\Persistence\Doctrine\SelectDoctrineQuery

Inheritance: extends AbstractDoctrineQuery, implements eZ\Publish\Core\Persistence\Database\SelectQuery
ファイルを表示 Open project: ezsystems/ezpublish-kernel Class Usage Examples

Public Properties

Property Type Description
$permissionSubtreeJoinAdded boolean Holds the state of permission subtree join, which is LEFT JOIN on 'ezcontentobject_tree' table with alias 'permission_subtree'.

Public Methods

Method Description
alias ( string $name, string $alias ) : string Returns SQL to create an alias.
from ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery Select which tables you want to select from.
getQuery ( ) : string Returns the query string for this query object.
groupBy ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery Returns SQL that groups the result set by a given column.
having ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery Returns SQL that set having by a given expression.
innerJoin ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery Returns the SQL for an inner join or prepares $fromString for an inner join.
leftJoin ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery Returns the SQL for a left join or prepares $fromString for a left join.
limit ( string $limit, string $offset = '' ) : eZ\Publish\Core\Persistence\Database\SelectQuery Returns SQL that limits the result set.
orderBy ( string $column, string $type = self::ASC ) : eZ\Publish\Core\Persistence\Database\SelectQuery Returns SQL that orders the result set by a given column.
rightJoin ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery Returns the SQL for a right join or prepares $fromString for a right join.
select ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery Opens the query and selects which columns you want to return with the query.
selectDistinct ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery Opens the query and uses a distinct select on the columns you want to return with the query.
where ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery Adds a where clause with logical expressions to the query.

Protected Methods

Method Description
doJoin ( string $type, array $args ) : eZ\Publish\Core\Persistence\Database\SelectQuery Helper function to generate join.

Method Details

alias() public method

This method can be used to create an alias for either a table or a column. Example: this will make the table users have the alias employees and the column user_id the alias employee_id $q->select( $q->alias( 'user_id', 'employee_id' ) ->from( $q->alias( 'users', 'employees' ) );
public alias ( string $name, string $alias ) : string
$name string
$alias string
return string the query string "columnname as targetname"

doJoin() protected method

Helper function to generate join.
protected doJoin ( string $type, array $args ) : eZ\Publish\Core\Persistence\Database\SelectQuery
$type string
$args array
return eZ\Publish\Core\Persistence\Database\SelectQuery

from() public method

from() accepts an arbitrary number of parameters. Each parameter must contain either the name of a table or an array containing the names of tables.. Each call to from() appends tables to the list of tables that will be used in the query. Example: the following code will produce the SQL SELECT id FROM table_name $q->select( 'id' )->from( 'table_name' );
public from ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery
return eZ\Publish\Core\Persistence\Database\SelectQuery a pointer to $this

getQuery() public method

Returns the query string for this query object.
public getQuery ( ) : string
return string

groupBy() public method

You can call groupBy multiple times. Each call will add a column to group by. Example: $q->select( '*' )->from( 'table' ) ->groupBy( 'id' );
public groupBy ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery
return eZ\Publish\Core\Persistence\Database\SelectQuery a pointer to $this

having() public method

You can call having multiple times. Each call will add an expression with a logical and. Example: $q->select( '*' )->from( 'table' )->groupBy( 'id' ) ->having( $q->expr->eq('id',1) );
public having ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery
return eZ\Publish\Core\Persistence\Database\SelectQuery a pointer to $this

innerJoin() public method

This method could be used in two forms: innerJoin( 't2', $joinCondition ) Takes 2 string arguments and returns \eZ\Publish\Core\Persistence\Database\SelectQuery. The first parameter is the name of the table to join with. The table to which is joined should have been previously set with the from() method. The second parameter should be a string containing a join condition that is returned by an \eZ\Publish\Core\Persistence\Database\SelectQueryExpression. Example: the following code will produce the SQL SELECT id FROM t1 INNER JOIN t2 ON t1.id = t2.id $q->select( 'id' )->from( 't1' )->innerJoin( 't2', $q->expr->eq('t1.id', 't2.id' ) ); innerJoin( 't2', 't1.id', 't2.id' ) Takes 3 string arguments and returns \eZ\Publish\Core\Persistence\Database\SelectQuery. This is a simplified form of the 2 parameter version. innerJoin( 't2', 't1.id', 't2.id' ) is equal to innerJoin( 't2', $this->expr->eq('t1.id', 't2.id' ) ); The first parameter is the name of the table to join with. The table to which is joined should have been previously set with the from() method. The second parameter is the name of the column on the table set previously with the from() method and the third parameter the name of the column to join with on the table that was specified in the first parameter. Example: the following code will produce the SQL SELECT id FROM t1 INNER JOIN t2 ON t1.id = t2.id $q->select( 'id' )->from( 't1' )->innerJoin( 't2', 't1.id', 't2.id' );
public innerJoin ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery
return eZ\Publish\Core\Persistence\Database\SelectQuery

leftJoin() public method

This method could be used in two forms: leftJoin( 't2', $joinCondition ) Takes 2 string arguments and returns \eZ\Publish\Core\Persistence\Database\SelectQuery. The first parameter is the name of the table to join with. The table to which is joined should have been previously set with the from() method. The second parameter should be a string containing a join condition that is returned by an \eZ\Publish\Core\Persistence\Database\SelectQueryExpression. Example: the following code will produce the SQL SELECT id FROM t1 LEFT JOIN t2 ON t1.id = t2.id $q->select( 'id' )->from( 't1' )->leftJoin( 't2', $q->expr->eq('t1.id', 't2.id' ) ); leftJoin( 't2', 't1.id', 't2.id' ) Takes 3 string arguments and returns \eZ\Publish\Core\Persistence\Database\SelectQuery. This is a simplified form of the 2 parameter version. leftJoin( 't2', 't1.id', 't2.id' ) is equal to leftJoin( 't2', $this->expr->eq('t1.id', 't2.id' ) ); The first parameter is the name of the table to join with. The table to which is joined should have been previously set with the from() method. The second parameter is the name of the column on the table set previously with the from() method and the third parameter the name of the column to join with on the table that was specified in the first parameter. Example: the following code will produce the SQL SELECT id FROM t1 LEFT JOIN t2 ON t1.id = t2.id $q->select( 'id' )->from( 't1' )->leftJoin( 't2', 't1.id', 't2.id' );
public leftJoin ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery
return eZ\Publish\Core\Persistence\Database\SelectQuery

limit() public method

$limit controls the maximum number of rows that will be returned. $offset controls which row that will be the first in the result set from the total amount of matching rows. Example: $q->select( '*' )->from( 'table' ) ->limit( 10, 0 ); LIMIT is not part of SQL92. It is implemented here anyway since all databases support it one way or the other and because it is essential.
public limit ( string $limit, string $offset = '' ) : eZ\Publish\Core\Persistence\Database\SelectQuery
$limit string integer expression
$offset string integer expression
return eZ\Publish\Core\Persistence\Database\SelectQuery

orderBy() public method

You can call orderBy multiple times. Each call will add a column to order by. Example: $q->select( '*' )->from( 'table' ) ->orderBy( 'id' );
public orderBy ( string $column, string $type = self::ASC ) : eZ\Publish\Core\Persistence\Database\SelectQuery
$column string a column name in the result set
$type string if the column should be sorted ascending or descending. you can specify this using \eZ\Publish\Core\Persistence\Database\SelectQuery::ASC or \eZ\Publish\Core\Persistence\Database\SelectQuery::DESC
return eZ\Publish\Core\Persistence\Database\SelectQuery a pointer to $this

rightJoin() public method

This method could be used in two forms: rightJoin( 't2', $joinCondition ) Takes 2 string arguments and returns \eZ\Publish\Core\Persistence\Database\SelectQuery. The first parameter is the name of the table to join with. The table to which is joined should have been previously set with the from() method. The second parameter should be a string containing a join condition that is returned by an \eZ\Publish\Core\Persistence\Database\SelectQueryExpression. Example: the following code will produce the SQL SELECT id FROM t1 LEFT JOIN t2 ON t1.id = t2.id $q->select( 'id' )->from( 't1' )->rightJoin( 't2', $q->expr->eq('t1.id', 't2.id' ) ); rightJoin( 't2', 't1.id', 't2.id' ) Takes 3 string arguments and returns \eZ\Publish\Core\Persistence\Database\SelectQuery. This is a simplified form of the 2 parameter version. rightJoin( 't2', 't1.id', 't2.id' ) is equal to rightJoin( 't2', $this->expr->eq('t1.id', 't2.id' ) ); The first parameter is the name of the table to join with. The table to which is joined should have been previously set with the from() method. The second parameter is the name of the column on the table set previously with the from() method and the third parameter the name of the column to join with on the table that was specified in the first parameter. Example: the following code will produce the SQL SELECT id FROM t1 LEFT JOIN t2 ON t1.id = t2.id $q->select( 'id' )->from( 't1' )->rightJoin( 't2', 't1.id', 't2.id' );
public rightJoin ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery
return eZ\Publish\Core\Persistence\Database\SelectQuery

select() public method

select() accepts an arbitrary number of parameters. Each parameter must contain either the name of a column or an array containing the names of the columns. Each call to select() appends columns to the list of columns that will be used in the query. Example: $q->select( 'column1', 'column2' ); The same could also be written $columns[] = 'column1'; $columns[] = 'column2; $q->select( $columns ); or using several calls $q->select( 'column1' )->select( 'column2' ); Each of above code produce SQL clause 'SELECT column1, column2' for the query.
public select ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery
return eZ\Publish\Core\Persistence\Database\SelectQuery returns a pointer to $this.

selectDistinct() public method

selectDistinct() accepts an arbitrary number of parameters. Each parameter must contain either the name of a column or an array containing the names of the columns. Each call to selectDistinct() appends columns to the list of columns that will be used in the query. Example: $q->selectDistinct( 'column1', 'column2' ); The same could also be written $columns[] = 'column1'; $columns[] = 'column2; $q->selectDistinct( $columns ); or using several calls $q->selectDistinct( 'column1' )->select( 'column2' ); Each of above code produce SQL clause 'SELECT DISTINCT column1, column2' for the query. You may call select() after calling selectDistinct() which will result in the additional columns beein added. A call of selectDistinct() after select() will result in an \eZ\Publish\Core\Persistence\Database\SelectQueryInvalidException.
public selectDistinct ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery
return eZ\Publish\Core\Persistence\Database\SelectQuery returns a pointer to $this.

where() public method

where() accepts an arbitrary number of parameters. Each parameter must contain a logical expression or an array with logical expressions. If you specify multiple logical expression they are connected using a logical and. Multiple calls to where() will join the expressions using a logical and. Example: $q->select( '*' )->from( 'table' )->where( $q->expr->eq( 'id', 1 ) );
public where ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery
return eZ\Publish\Core\Persistence\Database\SelectQuery

Property Details

$permissionSubtreeJoinAdded public_oe property

Holds the state of permission subtree join, which is LEFT JOIN on 'ezcontentobject_tree' table with alias 'permission_subtree'.
See also: eZ\Publish\Core\Search\Legacy\Content\Gateway\CriterionHandler\PermissionSubtree
See also: https://jira.ez.no/browse/EZP-23037
public bool $permissionSubtreeJoinAdded
return boolean