Methods summary
public
Horde_Db_Adapter_Postgresql_Column
|
#
makeColumn( string $name, string $default, string $sqlType = null, boolean $null = true )
Factory for Column objects.
Factory for Column objects.
Parameters
- $name
- <p>The column's name, such as "supplier_id" in
"supplier_id int(11)".</p>
- $default
- <p>The type-casted default value, such as "new" in
"sales_stage varchar(20) default 'new'".</p>
- $sqlType
- <p>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".</p>
- $null
- Whether this column allows NULL values.
Returns
Overrides
|
public
string
|
#
quote( mixed $value, object $column = null )
Quotes the column value to help prevent SQL injection attacks.
Quotes the column value to help prevent SQL injection attacks.
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.
Parameters
- $value
- <p>The scalar value to quote, a Horde_Db_Value,
Horde_Date, or DateTime instance, or an object
implementing quotedId().</p>
- $column
- An object implementing getType().
Returns
string The correctly quoted value.
Overrides
|
public
string
|
#
quoteColumnName( string $name )
Returns a quoted form of the column name.
Returns a quoted form of the column name.
Parameters
Returns
string The quoted column name.
|
public
string
|
#
quoteSequenceName( string $name )
Returns a quoted sequence name.
Returns a quoted sequence name.
PostgreSQL specific method.
Parameters
Returns
string The quoted sequence name.
|
public
string
|
#
quoteBinary( mixed $value )
Returns a quoted binary value.
Returns a quoted binary value.
Parameters
Returns
string The quoted binary value.
Overrides
|
public
array
|
#
nativeDatabaseTypes( )
Returns a hash of mappings from the abstract data types to the native
database types.
Returns a hash of mappings from the abstract data types to the native
database types.
See TableDefinition::column() for details on the recognized abstract
data types.
Returns
array A database type map.
See
TableDefinition::column()
Overrides
|
public
integer
|
#
tableAliasLength( )
Returns the maximum length a table alias can have.
Returns the maximum length a table alias can have.
Returns the configured supported identifier length supported by
PostgreSQL, or report the default of 63 on PostgreSQL 7.x.
Returns
integer The maximum table alias length.
Overrides
|
public
array
|
#
tables( )
Returns a list of all tables in the schema search path.
Returns a list of all tables in the schema search path.
Returns
array A table list.
|
public
Horde_Db_Adapter_Base_Index
|
#
primaryKey( string $tableName, string $name = null )
Returns a table's primary key.
Returns a table's primary key.
Parameters
- $tableName
- A table name.
- $name
- (can be removed?)
Returns
|
public
array
|
#
indexes( string $tableName, string $name = null )
Returns a list of tables indexes.
Returns a list of tables indexes.
Parameters
- $tableName
- A table name.
- $name
- (can be removed?)
Returns
array A list of Horde_Db_Adapter_Base_Index objects.
|
public
array
|
#
columns( string $tableName, string $name = null )
Returns a list of table columns.
Returns a list of table columns.
Parameters
- $tableName
- A table name.
- $name
- (can be removed?)
Returns
array A list of Horde_Db_Adapter_Base_Column objects.
|
public
|
#
renameTable( string $name, string $newName )
Renames a table.
Parameters
- $name
- A table name.
- $newName
- The new table name.
|
public
|
#
addColumn( string $tableName, string $columnName, string $type, array $options = array() )
Adds a new column to a table.
Adds a new column to a table.
Parameters
- $tableName
- A table name.
- $columnName
- A column name.
- $type
- A data type.
- $options
- <p>Column options. See
Horde_Db_Adapter_Base_TableDefinition#column()
for details.</p>
Overrides
|
public
|
#
changeColumn( string $tableName, string $columnName, string $type, array $options = array() )
Changes an existing column's definition.
Changes an existing column's definition.
Parameters
- $tableName
- A table name.
- $columnName
- A column name.
- $type
- A data type.
- $options
- <p>Column options. See
Horde_Db_Adapter_Base_TableDefinition#column()
for details.</p>
|
public
|
#
changeColumnDefault( string $tableName, string $columnName, mixed $default )
Sets a new default value for a column.
Sets a new default value for a column.
If you want to set the default value to NULL, you are out of luck. You
need to execute the apppropriate SQL statement yourself.
Parameters
- $tableName
- A table name.
- $columnName
- A column name.
- $default
- The new default value.
|
public
|
#
changeColumnNull( string $tableName, string $columnName, boolean $null, mixed $default = null )
Sets whether a column allows NULL values.
Sets whether a column allows NULL values.
Parameters
- $tableName
- A table name.
- $columnName
- A column name.
- $null
- Whether NULL values are allowed.
- $default
- The new default value.
|
public
|
#
renameColumn( string $tableName, string $columnName, string $newColumnName )
Renames a column.
Parameters
- $tableName
- A table name.
- $columnName
- A column name.
- $newColumnName
- The new column name.
|
public
|
#
removePrimaryKey( string $tableName )
Removes a primary key from a table.
Removes a primary key from a table.
Parameters
Throws
Since
Horde_Db 1.1.0
|
public
|
#
removeIndex( string $tableName, string|array $options = array() )
Removes an index from a table.
Removes an index from a table.
See parent class for examples.
Parameters
- $tableName
- A table name.
- $options
- <p>Either a column name or index options:
- name: (string) the index name.
- column: (string|array) column name(s).</p>
Overrides
|
public
|
#
createDatabase( string $name, array $options = array() )
Creates a database.
Parameters
- $name
- A database name.
- $options
- <p>Database options: owner, template, charset,
tablespace, and connection_limit.</p>
|
public
|
|
public
string
|
#
currentDatabase( )
Returns the name of the currently selected database.
Returns the name of the currently selected database.
Returns
string The database name.
|
public
string
|
#
typeToSql( string $type, integer $limit = null, integer $precision = null, integer $scale = null, boolean $unsigned = null )
Generates the SQL definition for a column type.
Generates the SQL definition for a column type.
Parameters
- $type
- A column type.
- $limit
- Maximum column length (non decimal type only)
- $precision
- The number precision (decimal type only).
- $scale
- The number scaling (decimal columns only).
- $unsigned
- <p>Whether the column is an unsigned number
(non decimal columns only).</p>
Returns
string The SQL definition. If $type is not one of the
internally supported types, $type is returned unchanged.
Overrides
|
public
string
|
#
distinct( string $columns, string $orderBy = null )
Generates a DISTINCT clause for SELECT queries.
Generates a DISTINCT clause for SELECT queries.
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')
Parameters
- $columns
- A column list.
- $orderBy
- An ORDER clause.
Returns
string The generated DISTINCT clause.
Overrides
|
public
string
|
#
addOrderByForAssociationLimiting( string $sql, array $options )
Adds an ORDER BY clause to an existing query.
Adds an ORDER BY clause to an existing query.
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.
Parameters
- $sql
- An SQL query to manipulate.
- $options
- <p>Options:
- order: Order column an direction.</p>
Returns
string The manipulated SQL query.
|
public
string
|
#
interval( string $interval, string $precision )
Generates an INTERVAL clause for SELECT queries.
Generates an INTERVAL clause for SELECT queries.
Parameters
- $interval
- The interval.
- $precision
- The precision.
Returns
string The generated INTERVAL clause.
|
public
string
|
#
modifyDate( string $reference, string $operator, integer $amount, string $interval )
Generates a modified date for SELECT queries.
Generates a modified date for SELECT queries.
Parameters
- $reference
- <p>The reference date - this is a column
referenced in the SELECT.</p>
- $operator
- Add or subtract time? (+/-)
- $amount
- <p>The shift amount (number of days if $interval
is DAY, etc).</p>
- $interval
- <p>The interval (SECOND, MINUTE, HOUR, DAY,
MONTH, YEAR).</p>
Returns
string The generated INTERVAL clause.
Since
Horde_Db 1.2.0
Overrides
|
public
string|array
|
#
buildClause( string $lhs, string $op, string $rhs, boolean $bind = false, array $params = array() )
Returns an expression using the specified operator.
Returns an expression using the specified operator.
Parameters
- $lhs
- The column or expression to test.
- $op
- The operator.
- $rhs
- The comparison value.
- $bind
- <p>If true, the method returns the query and a list
of values suitable for binding as an array.</p>
- $params
- Any additional parameters for the operator.
Returns
string|array The SQL test fragment, or an array containing the
query and a list of values if $bind is true.
Overrides
|
public
string
|
#
encoding( )
Returns the current database's encoding format.
Returns the current database's encoding format.
Returns
string The current database's encoding format.
|
public
|
#
setSchemaSearchPath( string $schemaCsv )
Sets the schema search path to a string of comma-separated schema names.
Sets the schema search path to a string of comma-separated schema names.
Names beginning with $ have to be quoted (e.g. $user => '$user'). See:
http://www.postgresql.org/docs/current/static/ddl-schemas.html
Parameters
- $schemaCsv
- A comma-separated schema name list.
|
public
string
|
#
getSchemaSearchPath( )
Returns the active schema search path.
Returns the active schema search path.
Returns
string The active schema search path.
|
public
string
|
#
getClientMinMessages( )
Returns the current client log message level.
Returns the current client log message level.
Returns
string The current client log message level.
|
public
|
#
setClientMinMessages( string $level )
Sets the client log message level.
Sets the client log message level.
Parameters
- $level
- <p>The client log message level. One of DEBUG5,
DEBUG4, DEBUG3, DEBUG2, DEBUG1, LOG, NOTICE,
WARNING, ERROR, FATAL, or PANIC.</p>
|
public
string
|
#
defaultSequenceName( string $tableName, string $pk = null )
Returns the sequence name for a table's primary key or some other
specified key.
Returns the sequence name for a table's primary key or some other
specified key.
If a sequence name doesn't exist, it is built from the table and primary
key name.
Parameters
- $tableName
- A table name.
- $pk
- <p>A primary key name. Overrides the existing key
name when building a new sequence name.</p>
Returns
string The key's sequence name.
|
public
integer
|
#
resetPkSequence( string $table, string $pk = null, string $sequence = null )
Resets the sequence of a table's primary key to the maximum value.
Resets the sequence of a table's primary key to the maximum value.
Parameters
- $table
- $tableName A table name.
- $pk
- <p>A primary key name. Defaults to the existing
primary key.</p>
- $sequence
- <p>A sequence name. Defaults to the sequence name
of the existing primary key.</p>
Returns
integer The (next) sequence value if a primary key and a
sequence exist.
|
public
array
|
#
pkAndSequenceFor( string $table )
Returns a table's primary key and the key's sequence.
Returns a table's primary key and the key's sequence.
Parameters
- $table
- $tableName A table name.
Returns
array Array with two values: the primary key name and the key's
sequence name.
|
public
integer
|
#
postgresqlVersion( )
Returns the version of the connected PostgreSQL server.
Returns the version of the connected PostgreSQL server.
Returns
integer Zero padded PostgreSQL version, e.g. 80108 for 8.1.8.
|