PHP Класс RedBeanPHP\QueryWriter\AQueryWriter

Represents an abstract Database to RedBean To write a driver for a different database for RedBean Contains a number of functions all implementors can inherit or override.
Автор: Gabor de Mooij and the RedBeanPHP Community
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$renames array
$typeno_sqltype array

Защищенные свойства (Protected)

Свойство Тип Описание
$adapter RedBeanPHP\Adapter\DBAdapter
$cache array
$defaultValue string
$flagUseCache boolean
$maxCacheSizePerType integer
$quoteCharacter string

Открытые методы

Метод Описание
addColumn ( $type, $column, $field )
addUniqueIndex ( $type, $properties )
camelsSnake ( string $camel ) : string Globally available service method for RedBeanPHP.
canBeTreatedAsInt ( string $value ) : boolean Checks whether a number can be treated like an int.
clearRenames ( ) : void Clears renames.
deleteRecord ( $type, $conditions = [], $addSql = NULL, $bindings = [] )
deleteRelations ( $sourceType, $destType, $sourceID )
esc ( $dbStructure, $dontQuote = FALSE )
flushCache ( $newMaxCacheSizePerType = NULL ) : integer Flushes the Query Writer Cache.
getAssocTable ( $types )
getAssocTableFormat ( $types )
getSQLFilters ( ) : array Returns current SQL Filters.
glueLimitOne ( $sql = '' )
glueSQLCondition ( $sql, $glue = NULL )
inferFetchType ( $type, $property )
queryRecord ( $type, $conditions = [], $addSql = NULL, $bindings = [] )
queryRecordCount ( $type, $conditions = [], $addSql = NULL, $bindings = [] )
queryRecordCountRelated ( $sourceType, $destType, $linkID, $addSql = '', $bindings = [] )
queryRecordLink ( $sourceType, $destType, $sourceID, $destID )
queryRecordRelated ( $sourceType, $destType, $linkIDs, $addSql = '', $bindings = [] )
queryRecordWithCursor ( $type, $addSql = NULL, $bindings = [] )
queryTagged ( $type, $tagList, $all = FALSE, $addSql = '', $bindings = [] )
renameAssocTable ( $from, $to = NULL )
renameAssociation ( $from, $to = NULL )
safeColumn ( string $column, boolean $noQuotes = FALSE ) : string
safeTable ( string $table, boolean $noQuotes = FALSE ) : string
setNarrowFieldMode ( boolean $narrowField ) : void Toggles 'Narrow Field Mode'.
setSQLFilters ( $sqlFilters, $safeMode = false ) : void Sets SQL filters.
setUseCache ( $yesNo ) : void Turns caching on or off. Default: off.
tableExists ( string $table ) : boolean Checks whether the specified type (i.e. table) already exists in the database.
updateRecord ( $type, $updatevalues, $id = NULL )
widenColumn ( $type, $property, $dataType )
wipe ( $type )
writeJoin ( $type, $targetType, $leftRight = 'LEFT' )

Защищенные методы

Метод Описание
addDataType ( integer $dataTypeID, string $SQLDefinition ) : self Adds a data type to the list of data types.
check ( $struct ) : string Checks table name or column name.
getForeignKeyForTypeProperty ( string $type, string $property ) : array | null Given a type and a property name this method returns the foreign key map section associated with this pair.
getInsertSuffix ( string $table ) : string Returns the sql that should follow an insert statement.
getKeyMapForType ( string $type ) : array Returns the foreign key map (FKM) for a type.
getParametersForInClause ( &$valueList, array $otherBindings, integer $offset ) : string Generates a list of parameters (slots) for an SQL snippet.
getSQLFilterSnippet ( string $type ) : string Returns an SQL Filter snippet for reading.
insertRecord ( $type, array $insertcolumns, array $insertvalues ) : integer Inserts a record into the database using a series of insert columns and corresponding insertvalues. Returns the insert id.
makeFKLabel ( string $from, string $type, string $to ) : string This method makes a key for a foreign key description array.
startsWithZeros ( string $value ) : boolean Checks whether a value starts with zeros. In this case the value should probably be stored using a text datatype instead of a numerical type in order to preserve the zeros.

Приватные методы

Метод Описание
getCacheKey ( array $keyValues ) : string Returns a cache key for the cache values passed.
getCached ( string $cacheTag, string $key ) : mixed Returns the values associated with the provided cache tag and key.
getRelationalTablesAndColumns ( string $sourceType, string $destType, boolean $noQuote = FALSE ) : array Returns the table names and column names for a relational query.
makeSQLFromConditions ( array $conditions, array &$bindings, string $addSql = '' ) : string Creates an SQL snippet from a list of conditions of format:
putResultInCache ( string $cacheTag, string $key, array $values ) : void Stores data from the writer in the cache under a specific key and cache tag.
updateCache ( ) : boolean Checks if the previous query had a keep-cache tag.

Описание методов

addColumn() публичный Метод

См. также: QueryWriter::addColumn
public addColumn ( $type, $column, $field )

addDataType() защищенный Метод

Use this method to add a new column type definition to the writer. Used for UUID support.
protected addDataType ( integer $dataTypeID, string $SQLDefinition ) : self
$dataTypeID integer magic number constant assigned to this data type
$SQLDefinition string SQL column definition (i.e. INT(11))
Результат self

addUniqueIndex() публичный Метод

См. также: QueryWriter::addUniqueConstraint
public addUniqueIndex ( $type, $properties )

camelsSnake() публичный статический Метод

Converts a camel cased string to a snake cased string.
public static camelsSnake ( string $camel ) : string
$camel string camelCased string to converty to snake case
Результат string

canBeTreatedAsInt() публичный статический Метод

Checks whether a number can be treated like an int.
public static canBeTreatedAsInt ( string $value ) : boolean
$value string string representation of a certain value
Результат boolean

check() защищенный Метод

Checks table name or column name.
protected check ( $struct ) : string
Результат string

clearRenames() публичный статический Метод

Clears renames.
public static clearRenames ( ) : void
Результат void

deleteRecord() публичный Метод

См. также: QueryWriter::deleteRecord
public deleteRecord ( $type, $conditions = [], $addSql = NULL, $bindings = [] )

deleteRelations() публичный Метод

См. также: QueryWriter::deleteRelations
public deleteRelations ( $sourceType, $destType, $sourceID )

esc() публичный Метод

См. также: QueryWriter::esc
public esc ( $dbStructure, $dontQuote = FALSE )

flushCache() публичный Метод

Clears the internal query cache array and returns its overall size.
public flushCache ( $newMaxCacheSizePerType = NULL ) : integer
Результат integer

getAssocTable() публичный Метод

См. также: QueryWriter::getAssocTable
public getAssocTable ( $types )

getAssocTableFormat() публичный статический Метод

См. также: QueryWriter::getAssocTableFormat
public static getAssocTableFormat ( $types )

getForeignKeyForTypeProperty() защищенный Метод

Given a type and a property name this method returns the foreign key map section associated with this pair.
protected getForeignKeyForTypeProperty ( string $type, string $property ) : array | null
$type string name of the type
$property string name of the property
Результат array | null

getInsertSuffix() защищенный Метод

Returns the sql that should follow an insert statement.
protected getInsertSuffix ( string $table ) : string
$table string name
Результат string

getKeyMapForType() защищенный Метод

A foreign key map describes the foreign keys in a table. A FKM always has the same structure: array( 'name' => 'from' => 'table' => 'to' => (most of the time 'id') 'on_update' => 'on_delete' => )
protected getKeyMapForType ( string $type ) : array
$type string the bean type you wish to obtain a key map of
Результат array

getParametersForInClause() защищенный Метод

This method calculates the correct number of slots to insert in the SQL snippet and determines the correct type of slot. If the bindings array contains named parameters this method will return named ones and update the keys in the value list accordingly (that's why we use the &). If you pass an offset the bindings will be re-added to the value list. Some databases cant handle duplicate parameter names in queries.
protected getParametersForInClause ( &$valueList, array $otherBindings, integer $offset ) : string
$otherBindings array list of additional bindings
$offset integer start counter at...
Результат string

getSQLFilterSnippet() защищенный Метод

Returns an SQL Filter snippet for reading.
protected getSQLFilterSnippet ( string $type ) : string
$type string type of bean
Результат string

getSQLFilters() публичный статический Метод

This method returns the raw SQL filter array. This is a lowlevel method. For a more friendly method please take a look at the facade: R::bindFunc().
public static getSQLFilters ( ) : array
Результат array

glueLimitOne() публичный Метод

См. также: QueryWriter::glueLimitOne
public glueLimitOne ( $sql = '' )

glueSQLCondition() публичный Метод

См. также: QueryWriter::glueSQLCondition
public glueSQLCondition ( $sql, $glue = NULL )

inferFetchType() публичный Метод

См. также: QueryWriter::inferFetchType
public inferFetchType ( $type, $property )

insertRecord() защищенный Метод

Inserts a record into the database using a series of insert columns and corresponding insertvalues. Returns the insert id.
protected insertRecord ( $type, array $insertcolumns, array $insertvalues ) : integer
$insertcolumns array columns to be inserted
$insertvalues array values to be inserted
Результат integer

makeFKLabel() защищенный Метод

This key is a readable string unique for every source table. This uniform key is called the FKDL Foreign Key Description Label. Note that the source table is not part of the FKDL because this key is supposed to be 'per source table'. If you wish to include a source table, prefix the key with 'on_table__'.
protected makeFKLabel ( string $from, string $type, string $to ) : string
$from string the column of the key in the source table
$type string the type (table) where the key points to
$to string the target column of the foreign key (mostly just 'id')
Результат string

queryRecord() публичный Метод

См. также: QueryWriter::queryRecord
public queryRecord ( $type, $conditions = [], $addSql = NULL, $bindings = [] )

queryRecordCount() публичный Метод

См. также: QueryWriter::queryRecordCount
public queryRecordCount ( $type, $conditions = [], $addSql = NULL, $bindings = [] )

queryRecordCountRelated() публичный Метод

См. также: QueryWriter::queryRecordCountRelated
public queryRecordCountRelated ( $sourceType, $destType, $linkID, $addSql = '', $bindings = [] )

queryRecordRelated() публичный Метод

См. также: QueryWriter::queryRecordRelated
public queryRecordRelated ( $sourceType, $destType, $linkIDs, $addSql = '', $bindings = [] )

queryRecordWithCursor() публичный Метод

См. также: QueryWriter::queryRecordWithCursor
public queryRecordWithCursor ( $type, $addSql = NULL, $bindings = [] )

queryTagged() публичный Метод

См. также: QueryWriter::queryTagged
public queryTagged ( $type, $tagList, $all = FALSE, $addSql = '', $bindings = [] )

renameAssocTable() публичный Метод

См. также: QueryWriter::renameAssocTable
public renameAssocTable ( $from, $to = NULL )

renameAssociation() публичный статический Метод

См. также: QueryWriter::renameAssociation
public static renameAssociation ( $from, $to = NULL )

safeColumn() публичный Метод

Устаревший: Use esc() instead.
public safeColumn ( string $column, boolean $noQuotes = FALSE ) : string
$column string column to be escaped
$noQuotes boolean omit quotes
Результат string

safeTable() публичный Метод

Устаревший: Use esc() instead.
public safeTable ( string $table, boolean $noQuotes = FALSE ) : string
$table string table to be escaped
$noQuotes boolean omit quotes
Результат string

setNarrowFieldMode() публичный статический Метод

In Narrow Field mode the queryRecord method will narrow its selection field to SELECT {table}.* instead of SELECT * This is a better way of querying because it allows more flexibility (for instance joins). However if you need the wide selector for backward compatibility; use this method to turn OFF Narrow Field Mode by passing FALSE.
public static setNarrowFieldMode ( boolean $narrowField ) : void
$narrowField boolean TRUE = Narrow Field FALSE = Wide Field
Результат void

setSQLFilters() публичный статический Метод

This is a lowlevel method to set the SQL filter array. The format of this array is: array( '' => array( '' => array( '' => '' ) ) ) Example: array( QueryWriter::C_SQLFILTER_READ => array( 'book' => array( 'title' => ' LOWER(book.title) ' ) ) Note that you can use constants instead of magical chars as keys for the uppermost array. This is a lowlevel method. For a more friendly method please take a look at the facade: R::bindFunc().
public static setSQLFilters ( $sqlFilters, $safeMode = false ) : void
Результат void

setUseCache() публичный Метод

If caching is turned on retrieval queries fired after eachother will use a result row cache.
public setUseCache ( $yesNo ) : void
Результат void

startsWithZeros() защищенный Метод

Checks whether a value starts with zeros. In this case the value should probably be stored using a text datatype instead of a numerical type in order to preserve the zeros.
protected startsWithZeros ( string $value ) : boolean
$value string value to be checked.
Результат boolean

tableExists() публичный Метод

Not part of the Object Database interface!
public tableExists ( string $table ) : boolean
$table string table name
Результат boolean

updateRecord() публичный Метод

См. также: QueryWriter::updateRecord
public updateRecord ( $type, $updatevalues, $id = NULL )

widenColumn() публичный Метод

См. также: QueryWriter::widenColumn
public widenColumn ( $type, $property, $dataType )

wipe() публичный Метод

См. также: QueryWriter::wipe
public wipe ( $type )

writeJoin() публичный Метод

См. также: QueryWriter::writeJoin
public writeJoin ( $type, $targetType, $leftRight = 'LEFT' )

Описание свойств

$adapter защищенное свойство

protected DBAdapter,RedBeanPHP\Adapter $adapter
Результат RedBeanPHP\Adapter\DBAdapter

$cache защищенное свойство

protected array $cache
Результат array

$defaultValue защищенное свойство

protected string $defaultValue
Результат string

$flagUseCache защищенное свойство

protected bool $flagUseCache
Результат boolean

$maxCacheSizePerType защищенное свойство

protected int $maxCacheSizePerType
Результат integer

$quoteCharacter защищенное свойство

protected string $quoteCharacter
Результат string

$renames публичное статическое свойство

public static array $renames
Результат array

$typeno_sqltype публичное свойство

public array $typeno_sqltype
Результат array