Class: MySQL_Driver
- 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: 1.2, 2002-07-16, $Id: MySQL.php,v 1.4 2007/09/01 17:02:17 lux Exp $
- Access: public
MySQL_Driver provides all of the MySQL-specific functionality
for Database objects. It is accessed through the Database class API.
New in 1.2:
- Added a close() method.
Usage Example
<?php
$db = new MySQL_Driver ("name", "host", "user", "pass", 1);
if ($db->connection) {
// connection worked
} else {
// connection failed
}
?>
Return to Top
Properties
$connection
Contains the database connection resource.
$path
Path to the Berkeley Database.
$mode
Mode to use when opening the database (corresponds to
the modes available to the dba_open () function.
$handler
The database implementation used (db2, db3, gdbm, etc.).
$persistent
A 1 or 0 (true or false, and true by default), specifying whether
to establish a persistent connection or not.
$transactions = 0
Boolean value denoting whether to enable transactions in the
current database.
$driver
Contains the name of the database driver being used.
$host
Contains the name of the database host.
$name
Contains the name of the database being used.
$user
Contains the username used to connect to the current database.
$pass
Contains the password used to connect to the current database.
$dbd
Contains the loaded database driver.
$error = false
Contains connection error information.
$sql = ''
Contains the SQL query to be executed.
$rows
Contains the number of rows returned by the previous fetch() call.
$lastid
Contains the lastid() of the last insert query sent to the execute()
method.
$tables = false
Contains a list of tables in the database. Set by getTables().
$pearEmu = false
$sequenceFormat = '%s_seq'
$fetchMode = DB_FETCHMODE_OBJECT
$result = ''
Contains the result identifier for the current execution.
$field = ''
Currently unused.
$_fetchModeFunctions = array (
DB_FETCHMODE_ASSOC => 'mysql_fetch_array',
DB_FETCHMODE_OBJECT => 'mysql_fetch_object',
)
Return to Top
Methods
MySQL_Driver ($name = "", $host = "", $user = "", $pass = "", $persistent = 1)
Constructor method.
connect ()
Establishes a connection with the database
query ($sql = "")
- Access: public
- Return: object
Creates and returns a Query object.
$sql is the SQL query you wish to execute with this object.
close ()
- Access: public
- Return: boolean
Disconnects from the database. This method is usually unnecessary
since connections should be automatically terminated or should persist after
the script finishes executing, depending on your settings.
getTables (&$db)
- Access: public
- Return: array
Retrieves a list of tables in the database and places them in the
$tables property, which is an array. Returns the list of names on
success and false on failure.
raiseError ($msg)
quote ($str)
createSequence ($seq_name)
Return to Top