The constructor. Can optionally have the database details passed to it, or alternatively it can use the globals (using the globals is deprecated functionality).
<<<< TODO throw E_USER_DEPRECATED after ensuring that Install and DocumentParser do not use the globals.
DBAPI_abstract
__construct
($parent $parent, [$host $host = ''], [$dbase $dbase = ''], [$uid $uid = ''], [$pwd $pwd = ''], [$pre $pre = null], [$charset $charset = ''], [$connection $connection_method = 'SET CHARACTER SET'])
-
$parent
$parent: Parent object e.g. $modx or $install
-
$host
$host: db hostname
-
$dbase
$dbase: db schema name
-
$uid
$uid: db username
-
$pwd
$pwd: db password
-
$pre
$pre: table prefix
-
$charset
$charset: client character set
-
$connection
$connection_method: SQL to set connection character set
Connect to the database.
Can optionally have the database details passed to it but this is deprecated functionality. Pass the details in the constructor instead.
void
connect
([$host $host = ''], [$dbase $dbase = ''], [$uid $uid = ''], [$pwd $pwd = ''], [$persist $persist = false])
-
$host
$host: db hostname
-
$dbase
$dbase: db schema name
-
$uid
$uid: db username
-
$pwd
$pwd: db password
-
$persist
$persist: If true, make a persistent connection.
Check for connection
void
connection_check
()
DELETE
resource
delete
(string $from, [string $where = ''], [string|array $fields = ''])
-
string
$from
-
string
$where
-
string|array
$fields
Disconnect from db.
RDBMS specific.
void
disconnect
()
Redefined in descendants as:
Escape a string
string
escape
(string $s)
Free memory associated with a resultset
void
freeResult
( $rs)
Redefined in descendants as:
Get the number of affected rows.
RDBMS specific.
int
getAffectedRows
()
Redefined in descendants as:
Returns an array of the values found on column $name
array
getColumn
(string $name, mixed $rsq)
-
string
$name: Column name
-
mixed
$rsq: Resultset or query string
Returns an array containing the column names in a resultset.
array
getColumnNames
(mixed $rsq)
-
mixed
$rsq: Resultset or query string
Get name of database.
string
getDBname
()
Get name of host.
string
getHostname
()
void
getHTMLGrid
(string|resource $rsq, array $params)
-
string|resource
$rsq: Resultset or SQL query
-
array
$params: 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
Get the last insert ID
void
getInsertId
()
Get the last error.
RDBMS specific.
string
getLastError
([ $return_number = false], string $type)
-
string
$type
-
$return_number
Redefined in descendants as:
Get the number of rows in a resultset. Return 0 if resultset invalid.
int
getRecordCount
(resource $rs)
Return an array of column values
array
getRow
(resource $rs, [string $mode = 'assoc'])
-
resource
$rs: Resultset
-
string
$mode: 'assoc', 'num' or 'both'.
Returns an array of structure detail for each column of a
array
getTableMetaData
(string $table)
-
string
$table: The full name of the database table
Redefined in descendants as:
Returns the value from the first column in the set.
string
getValue
(mixed $rsq)
-
mixed
$rsq: Resultset or query string
Returns a string containing the database server version
string
getVersion
()
Redefined in descendants as:
Returns an XML representation of the dataset $rsq
string
getXML
(mixed $rsq)
-
mixed
$rsq: Resultset or query string
Called in the constructor to set up arrays containing the types of database fields that can be used with specific PHP types.
RDBMS specific.
void
initDataTypes
()
Redefined in descendants as:
INSERT
mixed
insert
(string|array $fields, string $intotable, [string|array $fromfields = "*"], [string $fromtable = ''], [string $where = ''], [string $limit = ''])
-
string|array
$fields
-
string
$intotable
-
string|array
$fromfields
-
string
$fromtable
-
string
$where
-
string
$limit
INSERT IGNORE
mixed
insert_ignore
(string|array $fields, string $intotable, [string|array $fromfields = "*"], [string $fromtable = ''], [string $where = ''], [string $limit = ''])
-
string|array
$fields
-
string
$intotable
-
string|array
$fromfields
-
string
$fromtable
-
string
$where
-
string
$limit
Is a variable a resultset handle?
bool
is_handle
(mixed $var)
Redefined in descendants as:
Turns a recordset into a multidimensional array
mixed
makeArray
(resource $rs)
Connect to the RDBMS.
RDBMS specific.
void
make_connection
( $host, $uid, $pwd)
Redefined in descendants as:
Connect to the RDBMS persistently.
RDBMS specific.
void
make_persistent_connection
( $host, $uid, $pwd)
Redefined in descendants as:
Prepares a date in the proper format for specific database types given a UNIX timestamp
string
prepareDate
( $timestamp, [ $fieldType = 'DATETIME'], int $timestamp:, string $fieldType:)
-
int
$timestamp:: a UNIX timestamp
-
string
$fieldType:: the type of field to format the date for (in MySQL, you have DATE, TIME, YEAR, and DATETIME)
-
$timestamp
-
$fieldType
Make a persistent connection to the database.
void
p_connect
()
Query the database.
Developers should use select, update, insert (etc), delete where possible
resource
query
(string $sql, [bool $suppress_errors = false])
-
string
$sql
-
bool
$suppress_errors: If true, return false on error, otherwise quit via MessageQuit().
REPLACE
mixed
replace
(string|array $fields, string $intotable, [string|array $fromfields = "*"], [string $fromtable = ''], [string $where = ''], [string $limit = ''])
-
string|array
$fields
-
string
$intotable
-
string|array
$fromfields
-
string
$fromtable
-
string
$where
-
string
$limit
SELECT
resource
select
([string|array $fields = "*"], [string $from = ''], [string $where = ''], [string $orderby = ''], [string $limit = ''])
-
string|array
$fields
-
string
$from
-
string
$where
-
string
$orderby
-
string
$limit
Select a database.
RDBMS specific.
void
select_db
( $dbname)
Redefined in descendants as:
Set connection character set
RDBMS specific
void
set_charset
( $charset)
Redefined in descendants as:
Test for presence of Clipper db tables
bool;
tables_present
(string $prefix)
Redefined in descendants as:
Get table engine
string
table_engine
( $table)
Redefined in descendants as:
Test database connection or selection
Intended for installer use only. Does not set character set of connection.
Will return false on failure and will not log errors or display any errors via DocumentParser::MessageQuit().
void
test_connect
([$host $host = ''], [$dbase $dbase = ''], [$uid $uid = ''], [$pwd $pwd = ''], [$query $query = ''])
-
$host
$host: db hostname
-
$dbase
$dbase: Optional db schema name
-
$uid
$uid: db username
-
$pwd
$pwd: db password
-
$query
$query: Optional query to run
UPDATE
resource
update
(string|array $fields, string $table, [string $where = ''])
-
string|array
$fields
-
string
$table
-
string
$where
Escape a string,
RDBMS specific.
void
_escape
( $s)
Redefined in descendants as:
Get the column names in a resultset
RDBMS specific.
array
_getColumnNames
(mixed $rs)
Redefined in descendants as:
Get the last insert ID.
RDBMS specific.
void
_getInsertId
()
Redefined in descendants as:
Get a row into an associative array.
RDBMS specific.
void
_getRowAssoc
( $rs)
Redefined in descendants as:
Get a row into both an associative and numeric array.
RDBMS specific.
void
_getRowBoth
( $rs)
Redefined in descendants as:
Get a row into a numeric array.
RDBMS specific.
void
_getRowNumeric
( $rs)
Redefined in descendants as:
Make a query.
RDBMS specific.
void
_query
( $sql)
Redefined in descendants as:
Get the number of records in the resultset.
RDBMS specific.
void
_recordcount
( $rs)
Redefined in descendants as: