Overview

Packages

  • Db
    • Adapter
    • Migration

Classes

  • Horde_Db_Adapter_Base
  • Horde_Db_Adapter_Base_Column
  • Horde_Db_Adapter_Base_ColumnDefinition
  • Horde_Db_Adapter_Base_Index
  • Horde_Db_Adapter_Base_Schema
  • Horde_Db_Adapter_Base_Table
  • Horde_Db_Adapter_Base_TableDefinition
  • Horde_Db_Adapter_Mysql
  • Horde_Db_Adapter_Mysql_Column
  • Horde_Db_Adapter_Mysql_Result
  • Horde_Db_Adapter_Mysql_Schema
  • Horde_Db_Adapter_Mysqli
  • Horde_Db_Adapter_Mysqli_Result
  • Horde_Db_Adapter_Pdo_Base
  • Horde_Db_Adapter_Pdo_Mysql
  • Horde_Db_Adapter_Pdo_Pgsql
  • Horde_Db_Adapter_Pdo_Sqlite
  • Horde_Db_Adapter_Postgresql_Column
  • Horde_Db_Adapter_Postgresql_Schema
  • Horde_Db_Adapter_SplitRead
  • Horde_Db_Adapter_Sqlite_Column
  • Horde_Db_Adapter_Sqlite_Schema

Interfaces

  • Horde_Db_Adapter
  • Overview
  • Package
  • Class
  • Tree

Class Horde_Db_Adapter_Postgresql_Schema

Horde_Db_Adapter_Base_Schema
Extended by Horde_Db_Adapter_Postgresql_Schema
Package: Db\Adapter
Category: Horde
License: http://www.horde.org/licenses/bsd
Author: Mike Naberezny mike@maintainable.com
Author: Derek DeVries derek@maintainable.com
Author: Chuck Hagenbuch chuck@horde.org
Author: Jan Schneider jan@horde.org
Located at Horde/Db/Adapter/Postgresql/Schema.php
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

Horde_Db_Adapter_Postgresql_Column
A column object.

Overrides

Horde_Db_Adapter_Base_Schema::makeColumn()
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

Horde_Db_Adapter_Base_Schema::quote()
public string
# quoteColumnName( string $name )

Returns a quoted form of the column name.

Returns a quoted form of the column name.

Parameters

$name
A column name.

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

$name
A sequence name.

Returns

string
The quoted sequence name.
public string
# quoteBinary( mixed $value )

Returns a quoted binary value.

Returns a quoted binary value.

Parameters

$value
binary value.

Returns

string
The quoted binary value.

Overrides

Horde_Db_Adapter_Base_Schema::quoteBinary()
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

Horde_Db_Adapter_Base_Schema::nativeDatabaseTypes()
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

Horde_Db_Adapter_Base_Schema::tableAliasLength()
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

Horde_Db_Adapter_Base_Index
The primary key index object.
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.

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

Horde_Db_Adapter_Base_Schema::addColumn()
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.

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

$tableName
A table name.

Throws

Horde_Db_Exception

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

Horde_Db_Adapter_Base_Schema::removeIndex()
public
# createDatabase( string $name, array $options = array() )

Creates a database.

Creates a database.

Parameters

$name
A database name.
$options
<p>Database options: owner, template, charset, tablespace, and connection_limit.</p>
public
# dropDatabase( string $name )

Drops a database.

Drops a database.

Parameters

$name
A database name.
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

Horde_Db_Adapter_Base_Schema::typeToSql()
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

Horde_Db_Adapter_Base_Schema::distinct()
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

Horde_Db_Adapter_Base_Schema::modifyDate()
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

Horde_Db_Adapter_Base_Schema::buildClause()
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.
Methods inherited from Horde_Db_Adapter_Base_Schema
__call(), __construct(), __get(), addColumnOptions(), addIndex(), addOrderByForAssocLimiting(), addPrimaryKey(), createTable(), dropTable(), endTable(), indexName(), makeColumnDefinition(), makeIndex(), makeTable(), makeTableDefinition(), quoteDate(), quoteFalse(), quoteString(), quoteTableName(), quoteTrue(), recreateDatabase(), removeColumn(), setAdapter(), table(), tableAliasFor()
API documentation generated by ApiGen