Sitellite Application Framework
Class Tree         Index         All Elements

Class: MySQL_Query

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

Class Overview

Query
   |
   --MySQL_Query

MySQL_Driver is the Database driver for the MySQL database system.


Author(s)

Version

  • 1.6, 2002-07-09, $Id: MySQL.php,v 1.3 2006/09/26 08:32:17 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 64]
MySQL_Driver is the Database driver for the MySQL database system.

MySQL_Query provides all of the MySQL-specific functionality for Query objects. It is accessed through the Database class API.

New in 1.2:

  • Updated to work with saf.Database 2.0
New in 1.4:
  • Fixed a bug that caused the error () and errno () methods to return blank strings.
New in 1.6:
  • Removed the fetchXML() method, since it isn't necessary and simply inherits from the base Query class.

1 <?php
2
3 $q = new MySQL_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:  1.6, 2002-07-09, $Id: MySQL.php,v 1.3 2006/09/26 08:32:17 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 95]

The resource ID for the database connection to be queried.



Tags:

access:  public

Type:   mixed
Overrides:   Array


[ Top ]

$field =  ''

[line 87]

Currently unused.



Tags:

access:  public

Type:   mixed
Overrides:   Array


[ Top ]

$result =  ''

[line 79]

Contains the result identifier for the current execution.



Tags:

access:  public

Type:   mixed
Overrides:   Array


[ Top ]

$sql =  ''

[line 71]

Contains the SQL query to be executed.



Tags:

access:  public

Type:   mixed
Overrides:   Array


[ Top ]

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

[line 97]


Type:   mixed


[ Top ]



Class Methods


constructor MySQL_Query [line 113]

MySQL_Query MySQL_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 270]

void begin( )

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



Tags:

access:  public


[ Top ]

method commit [line 280]

void commit( )

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



Tags:

access:  public


[ Top ]

method errno [line 301]

integer errno( )

Returns the database error number in case of error.



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 312]

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 130]

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 211]

object fetch( [mixed $offset = 0], [mixed $limit = 0])

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



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 156]

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 257]

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 195]

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 290]

void rollback( )

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



Tags:

access:  public


[ Top ]

method rows [line 175]

integer rows( )

Returns the number of rows affected or found by the current query.



Tags:

access:  public


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

[ Top ]


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