Sitellite Application Framework
Class Tree         Index         All Elements

Class: PgSQL_Query

Source Location: Program_Root/Database/Driver/PgSQL.php

Class Overview

Query
   |
   --PgSQL_Query

PgSQL_Driver is the Database driver for the PostgreSQL database system.


Author(s)

Version

  • 0.6, 2003-04-03, $Id: PgSQL.php,v 1.2 2005/07/06 15:30:56 lux Exp $

Copyright

  • Copyright (C) 2001-2003, Simian Systems Inc.

Variables

Methods


Inherited Variables

Inherited Methods

Class: Query

Query::Query()
Constructor method.
Query::errno()
Returns the database error number in case of error. This number will be database-specific, and in some cases may even be a string. Please refer to your database documentation for a list of values and their meanings.
Query::error()
Returns the database error message in case of error. This message will be database-specific. Please refer to your database documentation for a list of messages and their meanings.
Query::execute()
Executes the current SQL query.
Query::fetch()
Returns the next row of data from the current query, always in the form of an object, with each column as its properties.
Query::fetchArray()
Returns the next row of data from the current query as an associative array, because sometimes an object isn't appropriate.
Query::fetchXML()
Returns the next row of data from the current query in XML format, so that it can easily be repurposed with XSL stylesheets or shared with external sources.
Query::field()
Returns the name of the specified column in the table currently being queried.
Query::free()
Tells the database system to let go of its data from the previous query.
Query::lastid()
Returns the row ID generated by the database during the previous SQL insert query.
Query::rows()
Returns the number of rows affected or found by the current query.
Query::toXML()
Returns the given result object represented as XML.

Class Details

[line 53]
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.


1 <?php
2
3 $q = new PgSQL_Query ("select * from table");
4 if ($q->execute ()) {
5 while ($row = $q->fetch ()) {
6 // do something with $row
7 }
8 $q->free ();
9 } else {
10 // query failed
11 }
12
13 ? >




Tags:

access:  public
version:  0.6, 2003-04-03, $Id: PgSQL.php,v 1.2 2005/07/06 15:30:56 lux Exp $
license:  http://www.sitellite.org/index/license
copyright:  Copyright (C) 2001-2003, Simian Systems Inc.
author:  John Luxford <mailto:lux@simian.ca>


[ Top ]


Class Variables

$connection =  ''

[line 84]

The resource ID for the database connection to be queried.



Tags:

access:  public

Type:   mixed
Overrides:   Array


[ Top ]

$field =  ''

[line 76]

Currently unused.



Tags:

access:  public

Type:   mixed
Overrides:   Array


[ Top ]

$result =  ''

[line 68]

Contains the result identifier for the current execution.



Tags:

access:  public

Type:   mixed
Overrides:   Array


[ Top ]

$sql =  ''

[line 60]

Contains the SQL query to be executed.



Tags:

access:  public

Type:   mixed
Overrides:   Array


[ Top ]



Class Methods


constructor PgSQL_Query [line 97]

PgSQL_Query PgSQL_Query( [string $sql = ''], resource &$conn, [mixed $cache = 0])

Constructor method.

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




Tags:

access:  public


Parameters:

string   $sql  
resource   $conn  

[ Top ]

method begin [line 250]

void begin( )

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



Tags:

access:  public


[ Top ]

method commit [line 260]

void commit( )

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



Tags:

access:  public


[ Top ]

method errno [line 283]

integer errno( )

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



Tags:

access:  public


Overrides Query::errno() (Returns the database error number in case of error. This number will be database-specific, and in some cases may even be a string. Please refer to your database documentation for a list of values and their meanings.)

[ Top ]

method error [line 294]

string error( )

Returns the database error message in case of error.



Tags:

access:  public


Overrides Query::error() (Returns the database error message in case of error. This message will be database-specific. Please refer to your database documentation for a list of messages and their meanings.)

[ Top ]

method execute [line 114]

resource execute( array $values)

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.




Tags:

access:  public


Overrides Query::execute() (Executes the current SQL query.)

Parameters:

array   $values  

[ Top ]

method fetch [line 206]

object fetch( )

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




Tags:

access:  public


Overrides Query::fetch() (Returns the next row of data from the current query, always in the form of an object, with each column as its properties.)

[ Top ]

method field [line 140]

string field( [integer $num = 0])

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.




Tags:

access:  public


Overrides Query::field() (Returns the name of the specified column in the table currently being queried.)

Parameters:

integer   $num  

[ Top ]

method free [line 237]

void free( )

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



Tags:

access:  public


Overrides Query::free() (Tells the database system to let go of its data from the previous query.)

[ Top ]

method lastid [line 188]

integer lastid( )

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



Tags:

access:  public


Overrides Query::lastid() (Returns the row ID generated by the database during the previous SQL insert query.)

[ Top ]

method rollback [line 270]

void rollback( )

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



Tags:

access:  public


[ Top ]

method rows [line 164]

integer rows( [boolean $useAffected = false])

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.




Tags:

access:  public


Overrides Query::rows() (Returns the number of rows affected or found by the current query.)

Parameters:

boolean   $useAffected  

[ Top ]


Copyright © 2007, SIMIAN systems Inc.
All rights reserved. Privacy policy
Documentation generated on Tue, 13 Feb 2007 17:18:40 -0600 by Sitellite AppDoc and phpDocumentor 1.2.2