Property | Type | Description | |
---|---|---|---|
$aliases | list of table aliases | ||
$params | the query parameters | ||
$sql | the complete SQL string for this query | ||
$sqlParts | the array of SQL parts collected | ||
$types | the parameter type map of this query |
Method | Description | |
---|---|---|
__toString ( ) : string | Gets a string representation of this QueryBuilder which corresponds to the final SQL query being constructed. | |
execute ( ) : integer | string | array | Execute this query using the bound parameters and their types | |
getParameter ( mixed $key ) : mixed | Gets a (previously set) query parameter of the query being constructed | |
getParameters ( ) : array | Gets all defined query parameters for the query being constructed | |
getQuery ( ) : string | Return the complete SQL string formed for use | |
getQueryPart ( string $queryPartName ) : mixed | Get a query part by its name | |
getSql ( ) : string | Return the complete SQL string formed by the current specifications | |
setParameter ( string | integer $key, mixed $value, integer $type = PDO::PARAM_STR ) | Sets a query parameter for the query being constructed | |
setParameters ( array $params, array $types = [] ) | Sets a collection of query parameters for the query being constructed |
Method | Description | |
---|---|---|
addQueryPart ( string $sqlPartName, string | array $sqlPart, boolean $append = false ) | Either appends to or replaces a single, generic query part | |
prepareCondition ( array $args = [] ) : string | Prepare condition | |
resetQueryPart ( string $queryPartName ) | Reset single SQL part | |
setFromQueryPart ( string $table ) | setFromQueryPart |
public __toString ( ) : string | ||
return | string | The string representation of this QueryBuilder. |
public getParameter ( mixed $key ) : mixed | ||
$key | mixed | The key (index or name) of the bound parameter |
return | mixed | The value of the bound parameter. |
public getParameters ( ) : array | ||
return | array | The currently defined query parameters |
$sb = new SelectBuilder();
$sb
->select('u')
->from('User', 'u')
->where('id = ?', 42);
echo $qb->getQuery(); // SELECT u FROM User u WHERE id = "42"
public getQueryPart ( string $queryPartName ) : mixed | ||
$queryPartName | string | |
return | mixed |
$sb = new SelectBuilder();
$sb
->select('u')
->from('User', 'u');
echo $qb->getSql(); // SELECT u FROM User u
$builder->prepareCondition("WHERE id IN (?)", [..,..]);
protected prepareCondition ( array $args = [] ) : string | ||
$args | array | |
return | string |
protected resetQueryPart ( string $queryPartName ) | ||
$queryPartName | string |
protected setFromQueryPart ( string $table ) | ||
$table | string |
$sb = new SelectBuilder();
$sb
->select('u')
->from('users', 'u')
->where('u.id = :user_id')
->setParameter(':user_id', 1);
$sb = new SelectBuilder();
$sb
->select('u')
->from('users', 'u')
->where('u.id = :user_id1 OR u.id = :user_id2')
->setParameters([
':user_id1' => 1,
':user_id2' => 2
]);
public setParameters ( array $params, array $types = [] ) | ||
$params | array | The query parameters to set |
$types | array | The query parameters types to set |