Query\QueryBuilder
Convenience class for creating sql queries
Synopsis
class QueryBuilder
extends QueryBuilderBase
implements
QueryBuilderInterface
{
- // methods
- public QueryBuilder select()
- public QueryBuilder selectMax()
- public QueryBuilder selectMin()
- public QueryBuilder selectAvg()
- public QueryBuilder selectSum()
- public QueryBuilder returning()
- public QueryBuilder distinct()
- public QueryBuilder explain()
- public QueryBuilder table()
- public QueryBuilder from()
- public QueryBuilder like()
- public QueryBuilder orLike()
- public QueryBuilder notLike()
- public QueryBuilder orNotLike()
- public QueryBuilder having()
- public QueryBuilder orHaving()
- public QueryBuilder where()
- public QueryBuilder orWhere()
- public QueryBuilder whereIn()
- public QueryBuilder orWhereIn()
- public QueryBuilder whereNotIn()
- public QueryBuilder orWhereNotIn()
- public QueryBuilder set()
- public QueryBuilder join()
- public QueryBuilder groupBy()
- public QueryBuilder orderBy()
- public QueryBuilder limit()
- public QueryBuilder groupStart()
- public QueryBuilder notGroupStart()
- public QueryBuilder orGroupStart()
- public QueryBuilder orNotGroupStart()
- public QueryBuilder groupEnd()
- public PDOStatement get()
- public PDOStatement getWhere()
- public int countAll()
- public int countAllResults()
- public PDOStatement insert()
- public ?PDOStatement insertBatch()
- public PDOStatement update()
- public ?int updateBatch()
- public PDOStatement delete()
- public string getCompiledSelect()
- public string getCompiledInsert()
- public string getCompiledUpdate()
- public string getCompiledDelete()
- // Inherited methods from QueryBuilderBase
- public void __construct()
- public void __destruct()
- public mixed __call()
- public void resetQuery()
Hierarchy
Violations
PHPMessDetector
Line | Rule | Message |
---|---|---|
80 | BooleanArgumentFlag | The method selectMax has a boolean flag argument $as, which is a certain sign of a Single Responsibility Principle violation. |
80 | ShortVariable | Avoid variables with short names like $as. Configured minimum length is 3. |
94 | BooleanArgumentFlag | The method selectMin has a boolean flag argument $as, which is a certain sign of a Single Responsibility Principle violation. |
94 | ShortVariable | Avoid variables with short names like $as. Configured minimum length is 3. |
108 | BooleanArgumentFlag | The method selectAvg has a boolean flag argument $as, which is a certain sign of a Single Responsibility Principle violation. |
108 | ShortVariable | Avoid variables with short names like $as. Configured minimum length is 3. |
122 | BooleanArgumentFlag | The method selectSum has a boolean flag argument $as, which is a certain sign of a Single Responsibility Principle violation. |
122 | ShortVariable | Avoid variables with short names like $as. Configured minimum length is 3. |
387 - 389 | ElseExpression | The method set uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. |
454 - 456 | ElseExpression | The method groupBy uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. |
657 | BooleanArgumentFlag | The method countAllResults has a boolean flag argument $reset, which is a certain sign of a Single Responsibility Principle violation. |
698 | UndefinedVariable | Avoid using undefined variables such as '$sql' which will lead to PHP notices. |
700 | UndefinedVariable | Avoid using undefined variables such as '$sql' which will lead to PHP notices. |
701 | UndefinedVariable | Avoid using undefined variables such as '$sql' which will lead to PHP notices. |
739 | UndefinedVariable | Avoid using undefined variables such as '$sql' which will lead to PHP notices. |
739 | UndefinedVariable | Avoid using undefined variables such as '$affectedRows' which will lead to PHP notices. |
741 | UndefinedVariable | Avoid using undefined variables such as '$sql' which will lead to PHP notices. |
742 | UndefinedVariable | Avoid using undefined variables such as '$affectedRows' which will lead to PHP notices. |
774 | BooleanArgumentFlag | The method getCompiledSelect has a boolean flag argument $reset, which is a certain sign of a Single Responsibility Principle violation. |
792 | BooleanArgumentFlag | The method getCompiledInsert has a boolean flag argument $reset, which is a certain sign of a Single Responsibility Principle violation. |
804 | BooleanArgumentFlag | The method getCompiledUpdate has a boolean flag argument $reset, which is a certain sign of a Single Responsibility Principle violation. |
816 | BooleanArgumentFlag | The method getCompiledDelete has a boolean flag argument $reset, which is a certain sign of a Single Responsibility Principle violation. |
Members
public
- $connName
—
string
Convenience property for connection management - $queries
—
array
List of queries executed
Methods
public
- countAll() — Retrieve the number of rows in the selected table
- countAllResults() — Retrieve the number of results for the generated query - used in place of the get() method
- delete() — Deletes data from a table
- distinct() — Adds the 'distinct' keyword to a query
- explain() — Tell the database to give you the query plan instead of result set
- from() — Specify the database table to select from
- get() — Select and retrieve all records from the current table, and/or execute current compiled query
- getCompiledDelete() — Returns the generated 'delete' sql query
- getCompiledInsert() — Returns the generated 'insert' sql query
- getCompiledSelect() — Returns the generated 'select' sql query
- getCompiledUpdate() — Returns the generated 'update' sql query
- getWhere() — Convenience method for get() with a where clause
- groupBy() — Group the results by the selected field(s)
- groupEnd() — Ends a query group
- groupStart() — Adds a paren to the current query for query grouping
- having() — Generates a 'Having' clause
- insert() — Creates an insert clause, and executes it
- insertBatch() — Creates and executes a batch insertion query
- join() — Creates a join phrase in a compiled query
- like() — Creates a Like clause in the sql statement
- limit() — Set a limit on the current sql statement
- notGroupStart() — Adds a paren to the current query for query grouping, prefixed with 'NOT'
- notLike() — Generates a NOT LIKE clause
- orGroupStart() — Adds a paren to the current query for query grouping, prefixed with 'OR'
- orHaving() — Generates a 'Having' clause prefixed with 'OR'
- orLike() — Generates an OR Like clause
- orNotGroupStart() — Adds a paren to the current query for query grouping, prefixed with 'OR NOT'
- orNotLike() — Generates a OR NOT LIKE clause
- orWhere() — Where clause prefixed with "OR"
- orWhereIn() — Where in statement prefixed with "or"
- orWhereNotIn() — OR WHERE NOT IN (FOO) clause
- orderBy() — Order the results by the selected field(s)
- returning() — Add a 'returning' clause to an insert,update, or delete query
- select() — Specifies rows to select in a query
- selectAvg() — Selects the average value of a field from a query
- selectMax() — Selects the maximum value of a field from a query
- selectMin() — Selects the minimum value of a field from a query
- selectSum() — Selects the sum of a field from a query
- set() — Sets values for inserts / updates / deletes
- table() — Specify the database table to select from
- update() — Creates an update clause, and executes it
- updateBatch() — Creates a batch update, and executes it.
- where() — Specify condition(s) in the where clause of a query Note: this function works with key / value, or a passed array with key / value pairs
- whereIn() — Where clause with 'IN' statement
- whereNotIn() — WHERE NOT IN (FOO) clause
Inherited from Query\QueryBuilderBase
public
- __call() — Calls a function further down the inheritance chain.
- resetQuery() — Clear out the class variables, so the next query can be run