Interface QueryWriter
QueryWriter Interface for QueryWriters. Describes the API for a QueryWriter.
Terminology:
- beautified property (a camelCased property, has to be converted first)
- beautified type (a camelCased type, has to be converted first)
- type (a bean type, corresponds directly to a table)
- property (a bean property, corresponds directly to a column)
- table (a checked and quoted type, ready for use in a query)
- column (a checked and quoted property, ready for use in query)
- tableNoQ (same as type, but in context of a database operation)
- columnNoQ (same as property, but in context of a database operation)
Direct known implementers
RedBeanPHP\QueryWriter\CUBRID, RedBeanPHP\QueryWriter\MySQL, RedBeanPHP\QueryWriter\PostgreSQL, RedBeanPHP\QueryWriter\SQLiteTCopyright:
copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community. This source file is subject to the BSD/GPLv2 License that is bundled with this source code in the file license.txt.
License: BSD/GPLv2
Author: Gabor de Mooij and the RedBeanPHP community
File: RedBeanPHP/QueryWriter.php
Located at QueryWriter.php
public
string
|
|
public
string
|
#
glueSQLCondition( string $sql, integer $glue = NULL )
Glues an SQL snippet to the beginning of a WHERE clause. This ensures users don't have to add WHERE to their query snippets. |
public
string
|
#
glueLimitOne( string $sql )
Determines if there is a LIMIT 1 clause in the SQL. If not, it will add a LIMIT 1. (used for findOne). |
public
array
|
|
public
|
#
createTable( string $type )
This method will create a table for the bean. This methods accepts a type and infers the corresponding table name. |
public
array
|
#
getColumns( string $type )
Returns an array containing all the columns of the specified type. The format of the return array looks like this: $field => $type where $field is the name of the column and $type is a database specific description of the datatype. |
public
integer
|
|
public
|
|
public
integer
|
#
code( string $typedescription, boolean $includeSpecials = FALSE )
Returns the Type Code for a Column Description. Given an SQL column description this method will return the corresponding code for the writer. If the include specials flag is set it will also return codes for special columns. Otherwise special columns will be identified as specified columns. |
public
|
#
widenColumn( string $type, string $column, integer $datatype )
This method will widen the column to the specified data type. This methods accepts a type and infers the corresponding table name. |
public
array
|
#
queryRecord( string $type, array $conditions = array(), string $addSql = NULL, array $bindings = array() )
Selects records from the database. This methods selects the records from the database that match the specified type, conditions (optional) and additional SQL snippet (optional). |
public
|
#
queryRecordWithCursor( string $type, array $addSql = NULL, string $bindings = array() , array $bindings,… )
Selects records from the database and returns a cursor. This methods selects the records from the database that match the specified type, conditions (optional) and additional SQL snippet (optional). |
public
array
|
#
queryRecordRelated( string $sourceType, string $destType, mixed $linkID, string $addSql = '', array $bindings = array() )
Returns records through an intermediate type. This method is used to obtain records using a link table and allows the SQL snippets to reference columns in the link table for additional filtering or ordering. |
public
array|null
|
#
queryRecordLink( string $sourceType, string $destType, string $sourceID, string $destID )
Returns the row that links $sourceType $sourcID to $destType $destID in an N-M relation. |
public
integer
|
#
queryRecordCount( string $type, array $conditions = array(), string $addSql = NULL, array $bindings = array() )
Counts the number of records in the database that match the conditions and additional SQL. |
public
integer
|
#
queryRecordCountRelated( string $sourceType, string $targetType, mixed $linkID, string $addSQL = '', array $bindings = array() )
Returns the number of records linked through $linkType and satisfying the SQL in $addSQL/$bindings. |
public
array
|
#
queryTagged( string $type, array $tagList, boolean $all = FALSE, string $addSql = '', array $bindings = array() )
Returns all rows of specified type that have been tagged with one of the strings in the specified tag list array. |
public
integer
|
#
updateRecord( string $type, array $updatevalues, integer $id = NULL )
This method should update (or insert a record), it takes a table name, a list of update values ( $field => $value ) and an primary key ID (optional). If no primary key ID is provided, an INSERT will take place. Returns the new ID. This methods accepts a type and infers the corresponding table name. |
public
|
#
deleteRecord( string $type, array $conditions = array(), string $addSql = '', array $bindings = array() )
Deletes records from the database. |
public
|
#
deleteRelations( string $sourceType, string $destType, string $sourceID )
Deletes all links between $sourceType and $destType in an N-M relation. |
public
|
|
public
|
#
addUniqueConstraint( string $type, array $columns )
This method will add a UNIQUE constraint index to a table on columns $columns. This methods accepts a type and infers the corresponding table name. |
public
boolean
|
#
sqlStateIn( string $state, array $list )
This method will check whether the SQL state is in the list of specified states and returns TRUE if it does appear in this list or FALSE if it does not. The purpose of this method is to translate the database specific state to a one of the constants defined in this class and then check whether it is in the list of standard states provided. |
public
|
|
public
|
#
addFK( string $type, string $targetType, string $property, string $targetProperty, string $isDep = false )
This method will add a foreign key from type and field to target type and target field. The foreign key is created without an action. On delete/update no action will be triggered. The FK is only used to allow database tools to generate pretty diagrams and to make it easy to add actions later on. This methods accepts a type and infers the corresponding table name. |
public
|
|
public
string
|
#
esc( string $databaseStructure, boolean $dontQuote = FALSE )
Checks and filters a database structure element like a table of column for safe use in a query. A database structure has to conform to the RedBeanPHP DB security policy which basically means only alphanumeric symbols are allowed. This security policy is more strict than conventional SQL policies and does therefore not require database specific escaping rules. |
public
|
|
public
|
#
renameAssocTable( string|array $fromType, string $toType = NULL )
Renames an association. For instance if you would like to refer to album_song as: track you can specify this by calling this method like: |
public
string
|
#
getAssocTable( array $types )
Returns the format for link tables. Given an array containing two type names this method returns the name of the link table to be used to store and retrieve association records. For instance, given two types: person and project, the corresponding link table might be: 'person_project'. |
public
string|null
|
#
inferFetchType( $type, $property )
Given a bean type and a property, this method tries to infer the fetch type using the foreign key definitions in the database. For instance: project, student -> person. If no fetchType can be inferred, this method will return NULL. |
string |
C_SQLFILTER_READ
SQL filter constants |
#
'r'
|
string |
C_SQLFILTER_WRITE
|
#
'w'
|
integer |
C_SQLSTATE_NO_SUCH_TABLE
Query Writer constants. |
#
1
|
integer |
C_SQLSTATE_NO_SUCH_COLUMN
|
#
2
|
integer |
C_SQLSTATE_INTEGRITY_CONSTRAINT_VIOLATION
|
#
3
|
integer |
C_DATATYPE_RANGE_SPECIAL
Define data type regions |
#
80
|
integer |
C_DATATYPE_RANGE_SPECIFIED
|
#
99
|
integer |
C_GLUE_WHERE
Define GLUE types for use with glueSQLCondition methods. Determines how to prefix a snippet of SQL before appending it to other SQL (or integrating it, mixing it otherwise). |
#
1
|
integer |
C_GLUE_AND
|
#
2
|