PHP Класс Horde_Db_Adapter_Postgresql_Schema, horde

Автор: Mike Naberezny ([email protected])
Автор: Derek DeVries ([email protected])
Автор: Chuck Hagenbuch ([email protected])
Автор: Jan Schneider ([email protected])
Наследование: extends Horde_Db_Adapter_Base_Schema
Показать файл Открыть проект

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

Свойство Тип Описание
$_schemaSearchPath string The active schema search path.
$_version integer Cached version.

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

Метод Описание
addColumn ( string $tableName, string $columnName, string $type, array $options = [] ) Adds a new column to a table.
addOrderByForAssociationLimiting ( string $sql, array $options ) : string Adds an ORDER BY clause to an existing query.
buildClause ( string $lhs, string $op, string $rhs, boolean $bind = false, array $params = [] ) : string | array Returns an expression using the specified operator.
changeColumn ( string $tableName, string $columnName, string $type, array $options = [] ) Changes an existing column's definition.
changeColumnDefault ( string $tableName, string $columnName, mixed $default ) Sets a new default value for a column.
changeColumnNull ( string $tableName, string $columnName, boolean $null, mixed $default = null ) Sets whether a column allows NULL values.
columns ( string $tableName, string $name = null ) : array Returns a list of table columns.
createDatabase ( string $name, array $options = [] ) Creates a database.
currentDatabase ( ) : string Returns the name of the currently selected database.
defaultSequenceName ( string $tableName, string $pk = null ) : string Returns the sequence name for a table's primary key or some other specified key.
distinct ( string $columns, string $orderBy = null ) : string Generates a DISTINCT clause for SELECT queries.
dropDatabase ( string $name ) Drops a database.
encoding ( ) : string Returns the current database's encoding format.
getClientMinMessages ( ) : string Returns the current client log message level.
indexes ( string $tableName, string $name = null ) : array Returns a list of tables indexes.
interval ( string $interval, string $precision ) : string Generates an INTERVAL clause for SELECT queries.
makeColumn ( string $name, string $default, string $sqlType = null, boolean $null = true ) : Horde_Db_Adapter_Postgresql_Column Factory for Column objects.
modifyDate ( string $reference, string $operator, integer $amount, string $interval ) : string Generates a modified date for SELECT queries.
nativeDatabaseTypes ( ) : array Returns a hash of mappings from the abstract data types to the native database types.
pkAndSequenceFor ( $table ) : array Returns a table's primary key and the key's sequence.
postgresqlVersion ( ) : integer Returns the version of the connected PostgreSQL server.
primaryKey ( string $tableName, string $name = null ) : Horde_Db_Adapter_Base_Index Returns a table's primary key.
quote ( mixed $value, object $column = null ) : string Quotes the column value to help prevent SQL injection attacks.
quoteBinary ( $value ) : string Returns a quoted binary value.
quoteFalse ( ) : string Returns a quoted boolean false.
quoteSequenceName ( string $name ) : string Returns a quoted sequence name.
quoteTrue ( ) : string Returns a quoted boolean true.
removeIndex ( string $tableName, string | array $options = [] ) Removes an index from a table.
removePrimaryKey ( string $tableName ) Removes a primary key from a table.
renameColumn ( string $tableName, string $columnName, string $newColumnName ) Renames a column.
renameTable ( string $name, string $newName ) Renames a table.
resetPkSequence ( $table, string $pk = null, string $sequence = null ) : integer Resets the sequence of a table's primary key to the maximum value.
setClientMinMessages ( string $level ) Sets the client log message level.
setSchemaSearchPath ( string $schemaCsv ) Sets the schema search path to a string of comma-separated schema names.
tableAliasLength ( ) : integer Returns the maximum length a table alias can have.
tables ( ) : array Returns a list of all tables in the schema search path.
typeToSql ( string $type, integer $limit = null, integer $precision = null, integer $scale = null, boolean $unsigned = null ) : string Generates the SQL definition for a column type.

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

Метод Описание
_columnDefinitions ( $tableName, $name = null ) Returns the list of a table's column names, data types, and default values.
_quoteBinaryCallback ( array $matches ) : string Callback function for quoteBinary().

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

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

The underlying query is roughly: SELECT column.name, column.type, default.value FROM column LEFT JOIN default ON column.table_id = default.table_id AND column.num = default.column_num WHERE column.table_id = get_table_id('table_name') AND column.num > 0 AND NOT column.is_dropped ORDER BY column.num If the table name is not prefixed with a schema, the database will take the first match from the schema search path. Query implementation notes: - format_type includes the column size constraint, e.g. varchar(50) - ::regclass is a function that gives the id for a table name
protected _columnDefinitions ( $tableName, $name = null )

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

Callback function for quoteBinary().
protected _quoteBinaryCallback ( array $matches ) : string
$matches array Matches from preg_replace().
Результат string Escaped/encoded binary value.

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

Adds a new column to a table.
public addColumn ( string $tableName, string $columnName, string $type, array $options = [] )
$tableName string A table name.
$columnName string A column name.
$type string A data type.
$options array Column options. See Horde_Db_Adapter_Base_TableDefinition#column() for details.

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

PostgreSQL does not allow arbitrary ordering when using DISTINCT ON, so we work around this by wrapping the $sql string as a sub-select and ordering in that query.
public addOrderByForAssociationLimiting ( string $sql, array $options ) : string
$sql string An SQL query to manipulate.
$options array Options: - order: Order column an direction.
Результат string The manipulated SQL query.

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

Returns an expression using the specified operator.
public buildClause ( string $lhs, string $op, string $rhs, boolean $bind = false, array $params = [] ) : string | array
$lhs string The column or expression to test.
$op string The operator.
$rhs string The comparison value.
$bind boolean If true, the method returns the query and a list of values suitable for binding as an array.
$params array Any additional parameters for the operator.
Результат string | array The SQL test fragment, or an array containing the query and a list of values if $bind is true.

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

Changes an existing column's definition.
public changeColumn ( string $tableName, string $columnName, string $type, array $options = [] )
$tableName string A table name.
$columnName string A column name.
$type string A data type.
$options array Column options. See Horde_Db_Adapter_Base_TableDefinition#column() for details.

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

If you want to set the default value to NULL, you are out of luck. You need to execute the apppropriate SQL statement yourself.
public changeColumnDefault ( string $tableName, string $columnName, mixed $default )
$tableName string A table name.
$columnName string A column name.
$default mixed The new default value.

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

Sets whether a column allows NULL values.
public changeColumnNull ( string $tableName, string $columnName, boolean $null, mixed $default = null )
$tableName string A table name.
$columnName string A column name.
$null boolean Whether NULL values are allowed.
$default mixed The new default value.

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

Returns a list of table columns.
public columns ( string $tableName, string $name = null ) : array
$tableName string A table name.
$name string (can be removed?)
Результат array A list of Horde_Db_Adapter_Base_Column objects.

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

Creates a database.
public createDatabase ( string $name, array $options = [] )
$name string A database name.
$options array Database options: owner, template, charset, tablespace, and connection_limit.

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

Returns the name of the currently selected database.
public currentDatabase ( ) : string
Результат string The database name.

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

If a sequence name doesn't exist, it is built from the table and primary key name.
public defaultSequenceName ( string $tableName, string $pk = null ) : string
$tableName string A table name.
$pk string A primary key name. Overrides the existing key name when building a new sequence name.
Результат string The key's sequence name.

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

PostgreSQL requires the ORDER BY columns in the SELECT list for distinct queries, and requires that the ORDER BY include the DISTINCT column. $connection->distinct('posts.id', 'posts.created_at DESC')
public distinct ( string $columns, string $orderBy = null ) : string
$columns string A column list.
$orderBy string An ORDER clause.
Результат string The generated DISTINCT clause.

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

Drops a database.
public dropDatabase ( string $name )
$name string A database name.

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

Returns the current database's encoding format.
public encoding ( ) : string
Результат string The current database's encoding format.

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

Returns the current client log message level.
public getClientMinMessages ( ) : string
Результат string The current client log message level.

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

Returns a list of tables indexes.
public indexes ( string $tableName, string $name = null ) : array
$tableName string A table name.
$name string (can be removed?)
Результат array A list of Horde_Db_Adapter_Base_Index objects.

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

Generates an INTERVAL clause for SELECT queries.
public interval ( string $interval, string $precision ) : string
$interval string The interval.
$precision string The precision.
Результат string The generated INTERVAL clause.

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

Factory for Column objects.
public makeColumn ( string $name, string $default, string $sqlType = null, boolean $null = true ) : Horde_Db_Adapter_Postgresql_Column
$name string The column's name, such as "supplier_id" in "supplier_id int(11)".
$default string The type-casted default value, such as "new" in "sales_stage varchar(20) default 'new'".
$sqlType string Used to extract the column's type, length and signed status, if necessary. For example "varchar" and "60" in "company_name varchar(60)" or "unsigned => true" in "int(10) UNSIGNED".
$null boolean Whether this column allows NULL values.
Результат Horde_Db_Adapter_Postgresql_Column A column object.

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

Generates a modified date for SELECT queries.
public modifyDate ( string $reference, string $operator, integer $amount, string $interval ) : string
$reference string The reference date - this is a column referenced in the SELECT.
$operator string Add or subtract time? (+/-)
$amount integer The shift amount (number of days if $interval is DAY, etc).
$interval string The interval (SECOND, MINUTE, HOUR, DAY, MONTH, YEAR).
Результат string The generated INTERVAL clause.

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

See TableDefinition::column() for details on the recognized abstract data types.
См. также: TableDefinition::column()
public nativeDatabaseTypes ( ) : array
Результат array A database type map.

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

Returns a table's primary key and the key's sequence.
public pkAndSequenceFor ( $table ) : array
Результат array Array with two values: the primary key name and the key's sequence name.

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

Returns the version of the connected PostgreSQL server.
public postgresqlVersion ( ) : integer
Результат integer Zero padded PostgreSQL version, e.g. 80108 for 8.1.8.

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

Returns a table's primary key.
public primaryKey ( string $tableName, string $name = null ) : Horde_Db_Adapter_Base_Index
$tableName string A table name.
$name string (can be removed?)
Результат Horde_Db_Adapter_Base_Index The primary key index object.

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

This method makes educated guesses on the scalar type based on the passed value. Make sure to correctly cast the value and/or pass the $column parameter to get the best results.
public quote ( mixed $value, object $column = null ) : string
$value mixed The scalar value to quote, a Horde_Db_Value, Horde_Date, or DateTime instance, or an object implementing quotedId().
$column object An object implementing getType().
Результат string The correctly quoted value.

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

Returns a quoted binary value.
public quoteBinary ( $value ) : string
Результат string The quoted binary value.

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

Returns a quoted boolean false.
public quoteFalse ( ) : string
Результат string The quoted boolean false.

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

PostgreSQL specific method.
public quoteSequenceName ( string $name ) : string
$name string A sequence name.
Результат string The quoted sequence name.

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

Returns a quoted boolean true.
public quoteTrue ( ) : string
Результат string The quoted boolean true.

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

See parent class for examples.
public removeIndex ( string $tableName, string | array $options = [] )
$tableName string A table name.
$options string | array Either a column name or index options: - name: (string) the index name. - column: (string|array) column name(s).

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

Removes a primary key from a table.
public removePrimaryKey ( string $tableName )
$tableName string A table name.

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

Renames a column.
public renameColumn ( string $tableName, string $columnName, string $newColumnName )
$tableName string A table name.
$columnName string A column name.
$newColumnName string The new column name.

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

Renames a table.
public renameTable ( string $name, string $newName )
$name string A table name.
$newName string The new table name.

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

Resets the sequence of a table's primary key to the maximum value.
public resetPkSequence ( $table, string $pk = null, string $sequence = null ) : integer
$pk string A primary key name. Defaults to the existing primary key.
$sequence string A sequence name. Defaults to the sequence name of the existing primary key.
Результат integer The (next) sequence value if a primary key and a sequence exist.

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

Sets the client log message level.
public setClientMinMessages ( string $level )
$level string The client log message level. One of DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, LOG, NOTICE, WARNING, ERROR, FATAL, or PANIC.

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

Names beginning with $ have to be quoted (e.g. $user => '$user'). See: http://www.postgresql.org/docs/current/static/ddl-schemas.html
public setSchemaSearchPath ( string $schemaCsv )
$schemaCsv string A comma-separated schema name list.

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

Returns the configured supported identifier length supported by PostgreSQL.
public tableAliasLength ( ) : integer
Результат integer The maximum table alias length.

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

Returns a list of all tables in the schema search path.
public tables ( ) : array
Результат array A table list.

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

Generates the SQL definition for a column type.
public typeToSql ( string $type, integer $limit = null, integer $precision = null, integer $scale = null, boolean $unsigned = null ) : string
$type string A column type.
$limit integer Maximum column length (non decimal type only)
$precision integer The number precision (decimal type only).
$scale integer The number scaling (decimal columns only).
$unsigned boolean Whether the column is an unsigned number (non decimal columns only).
Результат string The SQL definition. If $type is not one of the internally supported types, $type is returned unchanged.

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

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

The active schema search path.
protected string $_schemaSearchPath
Результат string

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

Cached version.
protected int $_version
Результат integer