Class DBAPI

Description

Legacy Database API class for MySQL.

  • author: Raymond Irving (June 2005)
  • author: Jason Coward <[email protected]>
  • deprecated: MODx Revolution - Use modX and xPDO functions instead in order to take advantage of support for any database platform with a PDO driver, as well as to take advantage of xPDO advanced caching features.

Located in /model/modx/dbapi.class.php (line 12)


	
			
Variable Summary
 mixed $config
 mixed $conn
 mixed $isConnected
 mixed $xpdo
Method Summary
 DBAPI __construct ([ $host = ''], [ $dbase = ''], [ $uid = ''], [ $pwd = ''], [ $pre = ''], [ $dbtype = ''])
 void connect ([ $host = ''], [ $dbase = ''], [ $uid = ''], [ $pwd = ''], [ $persist = 0])
 boolean delete (string $from, [string $where = ""], [string $fields = ''])
 void disconnect ()
 string escape (string $s)
 boolean exec (string $sql)
 integer getAffectedRows ([mixed $conn = null])
 array getColumn (string $name, mixed $dsq)
 array getColumnNames (mixed $dsq)
 string getHTMLGrid ($params $dsq,  $params)
 mixed getInsertId ([mixed $conn = null])
 string getLastError ()
 integer getRecordCount ( $ds)
 array getRow (mixed $ds, [string $mode = 'assoc'])
 array getTableMetaData (string $table)
 mixed getValue (mixed $dsq)
 string getXML (mixed $dsq)
 void initDataTypes ()
 mixed insert (mixed $fields, string $intotable, [string $fromfields = "*"], [string $fromtable = ""], [string $where = ""], [string $limit = ""])
 An makeArray ([$rs $rs = ''])
 string prepareDate ($timestamp $timestamp, [$fieldType $fieldType = 'DATETIME'])
 void query ( $sql)
 mixed select ([string $fields = "*"], [string $from = ""], [string $where = ""], [string $orderby = ""], [string $limit = ""])
 mixed update (mixed $fields, string $table, [string $where = ""])
Variables
mixed $affectedRows = false (line 17)
  • access: public
mixed $config (line 15)
  • access: public
mixed $conn (line 14)
  • access: public
mixed $isConnected (line 16)
  • access: public
mixed $xpdo (line 13)
  • access: public
Methods
Constructor __construct (line 22)

DBAPI constructor

DBAPI __construct ([ $host = ''], [ $dbase = ''], [ $uid = ''], [ $pwd = ''], [ $pre = ''], [ $dbtype = ''])
  • $host
  • $dbase
  • $uid
  • $pwd
  • $pre
  • $dbtype
connect (line 101)

Connect to database.

  • access: public
void connect ([ $host = ''], [ $dbase = ''], [ $uid = ''], [ $pwd = ''], [ $persist = 0])
  • $host
  • $dbase
  • $uid
  • $pwd
  • $persist
delete (line 168)

Delete a record from the DB

  • access: public
boolean delete (string $from, [string $where = ""], [string $fields = ''])
  • string $from
  • string $where
  • string $fields
disconnect (line 119)

Disconnect from the DB

  • access: public
void disconnect ()
escape (line 130)

Escape field data

  • access: public
string escape (string $s)
  • string $s
exec (line 272)

Execute an SQL query

  • return: Result of query.
  • access: public
boolean exec (string $sql)
  • string $sql
getAffectedRows (line 307)

Get affected rows by last query

  • access: public
integer getAffectedRows ([mixed $conn = null])
  • mixed $conn
getColumn (line 409)

Get an array of values for a column

  • access: public
array getColumn (string $name, mixed $dsq)
  • string $name
  • mixed $dsq
getColumnNames (line 428)

Returns an array of all the column names

  • access: public
array getColumnNames (mixed $dsq)
  • mixed $dsq
getHTMLGrid (line 545)

Get an HTML grid

  • access: public
string getHTMLGrid ($params $dsq,  $params)
  • $params $dsq: Data grid parameters columnHeaderClass tableClass itemClass altItemClass columnHeaderStyle tableStyle itemStyle altItemStyle columns fields colWidths colAligns colColors colTypes cellPadding cellSpacing header footer pageSize pagerLocation pagerClass pagerStyle
  • $params
getInsertId (line 296)

Get the last INSERTed primary key

  • access: public
mixed getInsertId ([mixed $conn = null])
  • mixed $conn
getLastError (line 317)

Get last error from DB

  • access: public
string getLastError ()
getRecordCount (line 327)

Get record count from last query

  • access: public
integer getRecordCount ( $ds)
  • $ds
getRow (line 349)

Gets a row of values from a result set

  • return: The row of column name - value pairs
  • access: public
array getRow (mixed $ds, [string $mode = 'assoc'])
  • mixed $ds
  • string $mode
getTableMetaData (line 488)

Returns an array of MySQL structure detail for each column of a table

  • access: public
array getTableMetaData (string $table)
  • string $table: the full name of the database table
getValue (line 448)

Returns the value from the first column in the set

  • access: public
mixed getValue (mixed $dsq)
  • mixed $dsq: Dataset or query string
getXML (line 464)

Returns an XML format of the dataset $ds

  • access: public
string getXML (mixed $dsq)
  • mixed $dsq: The dataset or query string
initDataTypes (line 54)

Called in the constructor to set up arrays containing the types of database fields that can be used with specific PHP types

  • access: public
void initDataTypes ()
insert (line 242)

Insert a record into the DB.

  • return: Either last id inserted or the result from the query
  • access: public
mixed insert (mixed $fields, string $intotable, [string $fromfields = "*"], [string $fromtable = ""], [string $where = ""], [string $limit = ""])
  • mixed $fields
  • string $intotable
  • string $fromfields
  • string $fromtable
  • string $where
  • string $limit
makeArray (line 592)

Turns a recordset into a multidimensional array

  • return: array of row arrays from recordset, or empty array if the recordset was empty, returns false if no recordset was passed
  • access: public
An makeArray ([$rs $rs = ''])
  • $rs $rs: Recordset to be packaged into an array
prepareDate (line 512)

Prepares a date in the proper format for specific database types given a UNIX timestamp

  • access: public
string prepareDate ($timestamp $timestamp, [$fieldType $fieldType = 'DATETIME'])
  • $timestamp $timestamp: A UNIX timestamp
  • $fieldType $fieldType: The type of field to format the date for (in MySQL, you have DATE, TIME, YEAR, and DATETIME)
query (line 142)

Mainly for internal use. Developers should use select, update, insert, delete where possible

  • access: public
void query ( $sql)
  • $sql
select (line 189)

Select a record from the DB

  • access: public
mixed select ([string $fields = "*"], [string $from = ""], [string $where = ""], [string $orderby = ""], [string $limit = ""])
  • string $fields
  • string $from
  • string $where
  • string $orderby
  • string $limit
update (line 210)

Update a record in the DB

  • access: public
mixed update (mixed $fields, string $table, [string $where = ""])
  • mixed $fields
  • string $table
  • string $where

Documentation generated on Fri, 17 Jun 2011 10:03:18 -0600 by phpDocumentor 1.4.3