Class: MySQL_DatabaseTable extends DatabaseTable
- 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.0, 2002-08-07, $Id: MySQL.php,v 1.4 2007/09/01 17:02:17 lux Exp $
- Access: public
MySQL_DatabaseTable provides all of the MySQL-specific functionality
for the saf.Database.Table package.
Usage Example
<?php
$dt = new MySQL_DatabaseTable ($db, 'tablename', 'pkeycolumn');
if ($res = $dt->fetchAll ()) {
// do something with $res
} else {
echo $dt->error;
}
?>
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',
)
$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',
)
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
getInfo ()
- Access: public
- Return: boolean
Gets all the info it can from the database about this table and
its columns, stores it in the $info property, and parses it into an
associative array ($columns) of MailForm widgets.
getPkey ()
- Access: public
- Return: string
Gets the name of the primary key field for this table using the
results of getInfo() (see below). Used by the constructor method to
set the $pkey property if a primary key column was not specified.
Returns false on failure.
getRefInfo ($name, $table)
- Access: public
- Return: boolean
Uses the global $tables array (Sitellite CMS specific) to get
the primary key, referencing column, display column, and a true or false
self-reference value, when given a Ref column name and its corresponding
table.
Return to Top