Class: PgSQL_Query extends Query

  • Package: saf.Database
  • Author: John Luxford <lux@simian.ca>
  • Copyright: Copyright (C) 2001-2003, Simian Systems Inc.
  • License: http://www.sitellite.org/index/license Simian Open Software License
  • Version: 0.6, 2003-04-03, $Id: PgSQL.php,v 1.2 2005/07/06 15:30:56 lux Exp $
  • Access: public

PgSQL_Driver is the Database driver for the PostgreSQL database system.
PgSQL_Query provides all of the PostgreSQL-specific functionality
for Query objects. It is accessed through the Database class API.


Usage Example


<?php

$q 
= new PgSQL_Query ("select * from table");
if (
$q->execute ()) {
    while (
$row $q->fetch ()) {
        
// do something with $row
    
}
    
$q->free ();
} else {
    
// query failed
}

?>

Return to Top



Properties


$connection = ''

  • Access: public

The resource ID for the database connection to be queried.


$path

  • Access: public

Path to the Berkeley Database.


$mode

  • Access: public

Mode to use when opening the database (corresponds to
the modes available to the dba_open () function.


$handler

  • Access: public

The database implementation used (db2, db3, gdbm, etc.).


$persistent

  • Access: public

A 1 or 0 (true or false, and true by default), specifying whether
to establish a persistent connection or not.


$transactions = 0

  • Access: public

Boolean value denoting whether to enable transactions in the
current database.


$driver

  • Access: public

Contains the name of the database driver being used.


$host

  • Access: public

Contains the name of the database host.


$name

  • Access: public

Contains the name of the database being used.


$user

  • Access: public

Contains the username used to connect to the current database.


$pass

  • Access: public

Contains the password used to connect to the current database.


$dbd

  • Access: private

Contains the loaded database driver.


$error = false

  • Access: public

Contains connection error information.


$sql = ''

  • Access: public

Contains the SQL query to be executed.


$rows

  • Access: public

Contains the number of rows returned by the previous fetch() call.


$lastid

  • Access: public

Contains the lastid() of the last insert query sent to the execute()
method.


$tables = false

  • Access: public

Contains a list of tables in the database. Set by getTables().


$pearEmu = false


$sequenceFormat = '%s_seq'


$fetchMode = DB_FETCHMODE_OBJECT


$result = ''

  • Access: public

Contains the result identifier for the current execution.


$field = ''

  • Access: public

Currently unused.


$_fetchModeFunctions = array (
        
DB_FETCHMODE_ASSOC        => 'mysql_fetch_array',
        
DB_FETCHMODE_OBJECT        => 'mysql_fetch_object',
    )


$typemap = array (
        
'(var)?char\(([0-9]+)\)'    => 'text',
        
'text'                        => 'textarea',
        
'mediumtext'                => 'textarea',
        
'longtext'                    => 'textarea',
        
'date'                        => 'date',
        
'time'                        => 'time',
        
'datetime'                    => 'datetime',
        
'timestamp\([0-9]+\)'            => 'datetime',
        
'enum\((.+)\)'                => 'select',
        
'set\((.+)\)'                => 'multiple',
        
'int\(([0-9]+)\)'            => 'text',
        
'blob'                        => 'textarea',
        
'.*'                            => 'text',
    )

  • Access: public

Contains a key/value list of database types (regular
expressions are used here to save repeating ourselves) and their
corresponding MailForm widget types.

Return to Top



Methods


PgSQL_Query ($sql = '', &$conn, $cache = 0)

  • Access: public

Constructor method.

$sql is the SQL query you wish to execute with this object.
$conn is the database connection resource to be queried.


execute ()

  • Access: public
  • Return: resource

Executes the current SQL query.

$values is an array of values to substitute. The syntax for denoting
bind_values in the SQL query is a double-questionmark (??).

Returns the new SQL query. Note: does not modify the actual $sql property.


field ($num = 0)

  • Access: public
  • Return: string

Returns the name of the specified column in the table currently being queried.

$num is the column number. Note: Some database systems begin with
column 0, while others with 1.


rows ($useAffected = false)

  • Access: public
  • Return: integer

Returns the number of rows affected or found by the current query.
This method differs from other drivers in that it accepts a single
$useAffected parameter, which tells the driver to use the pg_affected_rows()
function instead of pg_num_rows(). This should be set to 'true' on
INSERT, UPDATE, and DELETE queries.


lastid ()

  • Access: public
  • Return: integer

Returns the row ID generated by the database during the previous
SQL insert query.


fetch ()

  • Access: public
  • Return: object

Returns the next row of data from the current query, always in the
form of an object, with each column as its properties.

MISSING: ($offset, $limit) optional parameters


free ()

  • Access: public

Tells the database system to let go of its data from the previous
query.


begin ()

  • Access: public

Issues a mysql "begin" statement, beginning a transaction.


commit ()

  • Access: public

Issues a mysql "commit" statement, committing the current transaction.


rollback ()

  • Access: public

Issues a mysql "rollback" statement, rolling back the current transaction.


errno ()

  • Access: public
  • Return: integer

Returns the database error number in case of error. Always returns
0 for this driver, since there is no such function in the PostgreSQL
extension.


error ()

  • Access: public
  • Return: string

Returns the database error message in case of error.

Return to Top

Copyright © 2008 Sitellite CMS Project

Powered by Sitellite 5.0 Content Management System