DboPostgres Class Reference

Inheritance diagram for DboPostgres:

DboSource DataSource Object List of all members.

Public Member Functions

 _alterIndexes ($table, $indexes)
 _execute ($sql)
 alterSchema ($compare, $table=null)
 boolean ($data, $quote=true)
 buildColumn ($column)
 buildIndex ($indexes, $table=null)
 column ($real)
 connect ()
describe (&$model)
 disconnect ()
 fetchResult ()
 fields (&$model, $alias=null, $fields=array(), $quote=true)
 getEncoding ()
 getSequence ($table, $field= 'id')
 index ($model)
 lastAffected ()
 lastError ()
 lastInsertId ($source, $field= 'id')
 lastNumRows ()
 length ($real)
 limit ($limit, $offset=null)
 listSources ()
 name ($data)
 renderStatement ($type, $data)
 resultSet (&$results)
 setEncoding ($enc)
 truncate ($table, $reset=0)
 value ($data, $column=null, $read=true)

Public Attributes

 $_baseConfig
 $_commands
 $_sequenceMap = array()
 $columns
 $description = "PostgreSQL DBO Driver"
 $endQuote = '"'
 $startQuote = '"'

Detailed Description

Definition at line 36 of file dbo_postgres.php.


Member Function Documentation

DboPostgres::_alterIndexes ( table,
indexes 
)

Generate PostgreSQL index alteration statements for a table.

Parameters:
string $table Table to alter indexes for
array $new Indexes to add and drop
Returns:
array Index alteration statements

Definition at line 549 of file dbo_postgres.php.

References $out, column(), and name().

Referenced by alterSchema().

DboPostgres::_execute ( sql  ) 

Executes given SQL statement.

Parameters:
string $sql SQL statement
Returns:
resource Result resource identifier

Definition at line 147 of file dbo_postgres.php.

Referenced by connect().

DboPostgres::alterSchema ( compare,
table = null 
)

Alter the Schema of a table.

Parameters:
array $compare Results of CakeSchema::compare()
string $table name of the table public
Returns:
array

Reimplemented from DboSource.

Definition at line 478 of file dbo_postgres.php.

References $out, _alterIndexes(), buildColumn(), column(), DboSource::fullTableName(), and name().

DboPostgres::boolean ( data,
quote = true 
)

Translates between PHP boolean values and PostgreSQL boolean values

Parameters:
mixed $data Value to be translated
boolean $quote True to quote value, false otherwise
Returns:
mixed Converted boolean value

Definition at line 737 of file dbo_postgres.php.

Referenced by fetchResult().

DboPostgres::buildColumn ( column  ) 

Generate a Postgres-native column schema string

Parameters:
array $column An array structured like the following: array('name'=>'value', 'type'=>'value'[, options]), where options can be 'default', 'length', or 'key'.
Returns:
string

Reimplemented from DboSource.

Definition at line 777 of file dbo_postgres.php.

References $out, length(), and limit().

Referenced by alterSchema().

DboPostgres::buildIndex ( indexes,
table = null 
)

Format indexes for create table

Parameters:
array $indexes
string $table
Returns:
string

Reimplemented from DboSource.

Definition at line 809 of file dbo_postgres.php.

References $out, column(), and name().

DboPostgres::column ( real  ) 

Converts database-layer column types to basic types

Parameters:
string $real Real database-layer column type (i.e. "varchar(255)")
Returns:
string Abstract column type (i.e. "string")

Reimplemented from DataSource.

Definition at line 612 of file dbo_postgres.php.

References limit(), and name().

Referenced by _alterIndexes(), alterSchema(), buildIndex(), describe(), and index().

DboPostgres::connect (  ) 

Connects to the database using options in the given configuration array.

Returns:
True if successfully connected.

Definition at line 104 of file dbo_postgres.php.

References DataSource::$config, _execute(), config(), and setEncoding().

& DboPostgres::describe ( &$  model  ) 

Returns an array of the fields in given table name.

Parameters:
string $tableName Name of database table to inspect
Returns:
array Fields in table. Keys are name and type

Definition at line 185 of file dbo_postgres.php.

References column(), config(), DboSource::fetchAll(), DboSource::fullTableName(), length(), name(), and value().

DboPostgres::disconnect (  ) 

Disconnects from database.

Returns:
boolean True if the database could be disconnected, else false

Definition at line 130 of file dbo_postgres.php.

References DboSource::hasResult().

DboPostgres::fetchResult (  ) 

Fetches the next row from the current result set

Returns:
unknown

Definition at line 704 of file dbo_postgres.php.

References DboSource::$index, and boolean().

DboPostgres::fields ( &$  model,
alias = null,
fields = array(),
quote = true 
)

Generates the fields list of an SQL query.

Parameters:
Model $model
string $alias Alias tablename
mixed $fields
Returns:
array

Reimplemented from DboSource.

Definition at line 401 of file dbo_postgres.php.

References DboSource::$alias, __(), and name().

DboPostgres::getEncoding (  ) 

Gets the database encoding

Returns:
string The database encoding

Definition at line 766 of file dbo_postgres.php.

DboPostgres::getSequence ( table,
field = 'id' 
)

Gets the associated sequence for the given table/field

Parameters:
mixed $table Either a full table name (with prefix) as a string, or a model object
string $field Name of the ID database field. Defaults to "id"
Returns:
string The associated sequence name from the sequence map, defaults to "{$table}_{$field}_seq"

Definition at line 346 of file dbo_postgres.php.

DboPostgres::index ( model  ) 

Returns an array of the indexes in given datasource name.

Parameters:
string $model Name of model to inspect
Returns:
array Fields in table. Keys are column and unique

Reimplemented from DboSource.

Definition at line 438 of file dbo_postgres.php.

References DboSource::$index, column(), config(), DboSource::fullTableName(), and DboSource::query().

DboPostgres::lastAffected (  ) 

Returns number of affected rows in previous database operation. If no previous operation exists, this returns false.

Returns:
integer Number of affected rows

Definition at line 315 of file dbo_postgres.php.

DboPostgres::lastError (  ) 

Returns a formatted error message from previous database operation.

Returns:
string Error message

Definition at line 306 of file dbo_postgres.php.

DboPostgres::lastInsertId ( source,
field = 'id' 
)

Returns the ID generated from the previous INSERT operation.

Parameters:
string $source Name of the database table
string $field Name of the ID database field. Defaults to "id"
Returns:
integer

Definition at line 334 of file dbo_postgres.php.

DboPostgres::lastNumRows (  ) 

Returns number of rows in previous resultset. If no previous resultset exists, this returns false.

Returns:
integer Number of rows in resultset

Definition at line 324 of file dbo_postgres.php.

DboPostgres::length ( real  ) 

Gets the length of a database-native column description, or null if no length

Parameters:
string $real Real database-layer column type (i.e. "varchar(255)")
Returns:
int An integer representing the length of the column

Reimplemented from DboSource.

Definition at line 660 of file dbo_postgres.php.

Referenced by buildColumn(), and describe().

DboPostgres::limit ( limit,
offset = null 
)

Returns a limit statement in the correct format for the particular database.

Parameters:
integer $limit Limit of results returned
integer $offset Offset from which to start results
Returns:
string SQL limit/offset statement

Reimplemented from DboSource.

Definition at line 590 of file dbo_postgres.php.

Referenced by buildColumn(), and column().

DboPostgres::listSources (  ) 

Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.

Returns:
array Array of tablenames in the database

Definition at line 155 of file dbo_postgres.php.

References config(), DboSource::fetchAll(), and name().

DboPostgres::name ( data  ) 

Prepares field names to be quoted by parent

Parameters:
string $data
Returns:
string SQL field

Reimplemented from DboSource.

Definition at line 387 of file dbo_postgres.php.

References __(), and name().

Referenced by _alterIndexes(), alterSchema(), buildIndex(), column(), describe(), fields(), and listSources().

DboPostgres::renderStatement ( type,
data 
)

Overrides DboSource::renderStatement to handle schema generation with Postgres-style indexes

Parameters:
string $type
array $data
Returns:
string

Reimplemented from DboSource.

Definition at line 840 of file dbo_postgres.php.

References $columns, and DboSource::$index.

DboPostgres::resultSet ( &$  results  ) 

Enter description here...

Parameters:
unknown_type $results

Definition at line 680 of file dbo_postgres.php.

References DboSource::$index, and __().

DboPostgres::setEncoding ( enc  ) 

Sets the database encoding

Parameters:
mixed $enc Database encoding
Returns:
boolean True on success, false on failure

Definition at line 758 of file dbo_postgres.php.

Referenced by connect().

DboPostgres::truncate ( table,
reset = 0 
)

Deletes all the records in a table and drops all associated auto-increment sequences

Parameters:
mixed $table A string or model class representing the table to be truncated
integer $reset If -1, sequences are dropped, if 0 (default), sequences are reset, and if 1, sequences are not modified
Returns:
boolean SQL TRUNCATE TABLE statement, false if not applicable. public

Definition at line 365 of file dbo_postgres.php.

DboPostgres::value ( data,
column = null,
read = true 
)

Returns a quoted and escaped string of $data for use in an SQL statement.

Parameters:
string $data String to be prepared for use in an SQL statement
string $column The column into which this data will be inserted
boolean $read Value to be used in READ or WRITE context
Returns:
string Quoted and escaped
Todo:
Add logic that formats/escapes data based on column type

Reimplemented from DboSource.

Definition at line 260 of file dbo_postgres.php.

Referenced by describe().


Member Data Documentation

DboPostgres::$_baseConfig

Initial value:

 array(
        'connect'   => 'pg_pconnect',
        'persistent' => true,
        'host' => 'localhost',
        'login' => 'root',
        'password' => '',
        'database' => 'cake',
        'schema' => 'public',
        'port' => 5432,
        'encoding' => ''
    )

Reimplemented from DataSource.

Definition at line 61 of file dbo_postgres.php.

DboPostgres::$_commands

Initial value:

 array(
        'begin'    => 'BEGIN',
        'commit'   => 'COMMIT',
        'rollback' => 'ROLLBACK'
    )

Reimplemented from DboSource.

Definition at line 50 of file dbo_postgres.php.

DboPostgres::$_sequenceMap = array()

Definition at line 98 of file dbo_postgres.php.

DboPostgres::$columns

Initial value:

 array(
        'primary_key' => array('name' => 'serial NOT NULL'),
        'string' => array('name'  => 'varchar', 'limit' => '255'),
        'text' => array('name' => 'text'),
        'integer' => array('name' => 'integer', 'formatter' => 'intval'),
        'float' => array('name' => 'float', 'formatter' => 'floatval'),
        'datetime' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
        'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
        'time' => array('name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'),
        'date' => array('name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'),
        'binary' => array('name' => 'bytea'),
        'boolean' => array('name' => 'boolean'),
        'number' => array('name' => 'numeric'),
        'inet' => array('name'  => 'inet')
    )

Definition at line 73 of file dbo_postgres.php.

Referenced by renderStatement().

DboPostgres::$description = "PostgreSQL DBO Driver"

Reimplemented from DboSource.

Definition at line 43 of file dbo_postgres.php.

DboPostgres::$endQuote = '"'

Reimplemented from DataSource.

Definition at line 91 of file dbo_postgres.php.

DboPostgres::$startQuote = '"'

Reimplemented from DataSource.

Definition at line 89 of file dbo_postgres.php.


The documentation for this class was generated from the following file:
Generated on Sun Nov 22 00:30:55 2009 for CakePHP 1.2.x.x (v1.2.4.8284) by doxygen 1.4.7