Stud.IP
5.4
|
Public Member Functions | |
__construct (string $table, string $query_name= '') | |
select ($select, $statement=null) | |
join ($alias, $table=null, $on= '', $join= 'INNER JOIN') | |
where ($name, $condition=null, $parameter=[]) | |
having ($name, $condition=null, $parameter=[]) | |
parameter ($param, $value=null) | |
removeWhereCondition ($name) | |
groupBy ($clause) | |
orderBy ($clause) | |
limit ($start, $end=null) | |
count () | |
fetchAll ($sorm_class_or_column=null) | |
show () | |
Static Public Member Functions | |
static | table (string $table, string $query_name= '') |
Data Fields | |
$settings | |
$name = '' | |
Protected Member Functions | |
getQuery () | |
getPrimaryKey () | |
Class SQLQuery This class is to MANAGE a query that is maybe more complex than a standard sql-query. You can easily add filters, joins and additional select-parts.
$query = SQLQuery::table("auth_user_md5") ->join("seminar_user", "seminar_user.user_id = auth_user_md5.user_id") ->join("seminar_inst", "seminar_inst.seminar_id = seminar_user.Seminar_id") ->where("seminar_inst.institut_id = :institut_id",array('institut_id' => $inst->getId())); if (Request::get("status") { $query->where("auth_user_md5.status = :status", array('status' => Request::get("status")); } if ($query->count() <= 500) { $user_data = $query->fetchAll(); } else { PageLayout::postInfo(_("Geben Sie mehr Filter ein.")); }
__construct | ( | string | $table, |
string | $query_name = '' |
||
) |
Constructor of the query. A main table is needed.
string | $table | : a database table |
string | name : |
count | ( | ) |
Fetches the number of entries of the resultset.
fetchAll | ( | $sorm_class_or_column = null | ) |
Fetches the whole resultset as an array of associative arrays. If you define a sorm_class the result will be an array of the sorm-objects.
$sorm_class_or_column | : column name, a class of SimpleORMap or null for associative array. |
|
protected |
Fetches the primary key of the table and returns it as an array.
|
protected |
Constructs a query string for a prepared statement without the SELECT part.
groupBy | ( | $clause | ) |
Sets the grouping of the resultset.
string | $clause | : the clause to sort after like "auth_user_md5.user_id" |
having | ( | $name, | |
$condition = null , |
|||
$parameter = [] |
|||
) |
join | ( | $alias, | |
$table = null , |
|||
$on = '' , |
|||
$join = 'INNER JOIN' |
|||
) |
Joins a table to the query. You can omit $table and just call join($tablename, $on, $join) if you don't need an alias.
$alias | : table-name or an alias. | |
null | $table | : optional table name. Use this if you want to use an alias. |
string | $on | : any condition like "t1.user_id = t2.id" |
string | $join | : type of joining "INNER JOIN" or "LEFT JOIN" |
limit | ( | $start, | |
$end = null |
|||
) |
Limits the resultset of the query.
integer | $start | |
null | integer | $end |
orderBy | ( | $clause | ) |
Sets the order of the resultset.
string | $clause | : the clause to sort after like "Vorname ASC, position DESC" |
parameter | ( | $param, | |
$value = null |
|||
) |
Sets one or more parameter for this query.
array | string | $param | : associative array or string |
null | string | $value | : value of parameter when $param is a string |
removeWhereCondition | ( | $name | ) |
Removes a formerly defined where condition identified by its name.
$name | : the name of the where-condition that was defined in where-method.. |
select | ( | $select, | |
$statement = null |
|||
) |
show | ( | ) |
Shows the query that would be executed in the method fetchAll
|
static |
where | ( | $name, | |
$condition = null , |
|||
$parameter = [] |
|||
) |
Adds a condition to the query. Any conditions will get concatenated by AND.
$name | : the name of the condition. Use any name. It will be treated as an identifier. | |
null | $condition | |
array | $parameter |
$name = '' |
$settings |