This is the abstract class database
This is the generic implementation of the database class.
subpackage |
Database |
---|---|
package |
Subsystems |
__construct( $username, $password, $hostname, $database, $new = false)
adjustNestedTreeBetween( $table, $lft, $rgt, $width) : void
adjustNestedTreeFrom( $table, $start, $width) : void
alterTable(string $tablename, array $newdatadef, array $info, boolean $aggressive = false) : array
Alters the structure of an existing database table to conform to the passed data definition.
This function abides by the Exponent Data Definition Language, and interprets its general structure for databases.
string
The name of the table to alter
array
The new data definition for the table. This is expressed in the Exponent Data Definition Language
array
Information about the table itself.
boolean
Whether or not to aggressively update the table definition. An aggressive update will drop columns in the table that are not in the Exponent definition.
array
columnUpdate( $table, $col, $val, integer|null $where = 1) : void
integer|null
countObjects(string $table, string $where = null, boolean $is_revisioned = false, boolean $needs_approval = false, null $user = null) : integer
string
The name of the table to count objects in.
string
Criteria for counting.
boolean
boolean
null
integer
countObjectsBySql(string $sql) : integer
string
The sql query to be run
integer
createTable(string $tablename, array $datadef, array $info) : array
Creates a new database table, according to the passed data definition.
This function abides by the Exponent Data Definition Language, and interprets its general structure for databases.
string
The name of the table to create
array
The data definition to create, expressed in the Exponent Data Definition Language.
array
Information about the table itself.
array
databaseInfo() : array
This function effectively calls tableInfo() on each table found.
array
decrement(string $table, string $field, integer $step, string $where = null)
string
The name of the table to decrement in.
string
The field to decrement.
integer
The step value. Usually 1. This can be negative, to increment, but the increment() method is preferred, for readability.
string
Optional criteria to determine which records to update.
delete(string $table, string $where = null) : mixed
string
The name of the table to delete from.
string
Criteria for determining which record(s) to delete.
mixed
deleteNestedNode( $table, $lft, $rgt) : void
describeTable( $table)
dropTable(string $table) : boolean
Removes an existing table from the database. Returns true if the table was dropped, false if there was an error returned by the database server.
string
The name of the table to drop.
boolean
error() : string
string
escapeString( $string) : string
string
getDataDefinition(string $table) : array|null
string
The name of the table to get a data definition for.
array|null
getTables(boolean $prefixed_only = true) : array
boolean
Whether to return only the tables for the logical database, or all tables in the physical database.
array
getTextColumns( $table) : array
array
increment(string $table, string $field, integer $step, string $where = null) : mixed
string
The name of the table to increment in.
string
The field to increment.
integer
The step value. Usually 1. This can be negative, to decrement, but the decrement() method is preferred, for readability.
string
Optional criteria to determine which records to update.
mixed
inError() : boolean
boolean
injectProof( $string) : string
string
insertObject(object $object, string $table) : integer|void
This method will return the ID assigned to the new record by database. Note that object attributes starting with an underscore ('_') will be ignored and NOT inserted into the table as a field value.
object
The object to insert.
string
The logical table name to insert into. This does not include the table prefix, which is automagically prepended for you.
integer|void
isValid() : boolean
boolean
True if the connection can be used to execute SQL queries.
limit( $num, $offset) : string
string
lockTable( $table, string $lockType = "WRITE") : mixed
string
mixed
max(string $table, string $attribute, string $groupfields = null, string $where = null) : mixed
.. query.
string
The name of the table to select from.
string
The attribute name to find a maximum value for.
string
A comma-separated list of fields (or a single field) name, used for a GROUP BY clause. This can also be passed as an array of fields.
string
Optional criteria for narrowing the result set.
mixed
optimize(string $table) : boolean
string
The name of the table to optimize.
boolean
queryRows(string $sql) : integer|void
string
The sql query to be run
integer|void
selectAndJoinObjects(null $colsA = null, null $colsB = null, $tableA, $tableB, $keyA, null $keyB = null, null $where = null, null $orderby = null)
null
null
null
null
null
selectArray(string $table, string $where = null, null $orderby = null, boolean $is_revisioned = false, boolean $needs_approval = false, null $user = null) : array|void
string
The name of the table/object to look at
string
Criteria used to narrow the result set. If this is specified as null, then no criteria is applied, and all objects are returned
null
boolean
boolean
null
array|void
selectArrays(string $table, string $where = null, string $orderby = null, boolean $is_revisioned = false, boolean $needs_approval = false, null $user = null) : array
Selects a set of arrays from the database. Because of the way Exponent handles objects and database tables, this is akin to SELECTing a set of records from a database table. Returns an array of arrays, in any random order.
string
The name of the table/object to look at
string
Criteria used to narrow the result set. If this is specified as null, then no criteria is applied, and all objects are returned
string
boolean
boolean
null
array
selectArraysBySql(string $sql) : array
Selects a set of arrays from the database. Because of the way Exponent handles objects and database tables, this is akin to SELECTing a set of records from a database table. Returns an array of arrays, in any random order.
string
The name of the table/object to look at
array
selectColumn( $table, $col, null $where = null, null $orderby = null, boolean $distinct = false) : array
null
null
boolean
array
selectDropdown( $table, $col, null $where = null, null $orderby = null) : array
null
null
array
selectExpObjects(string $table, string $where = null, $classname, boolean $get_assoc = true, boolean $get_attached = true, array $except = array(), boolean $cascade_except = false, null $order = null, null $limitsql = null, boolean $is_revisioned = false, boolean $needs_approval = false, null $user = null) : array
string
The name of the table/object to look at
string
Criteria used to narrow the result set. If this is specified as null, then no criteria is applied, and all objects are returned
boolean
boolean
array
boolean
null
null
boolean
boolean
null
array
selectExpObjectsBySql(string $sql, string $classname, boolean $get_assoc = true, boolean $get_attached = true)
string
The sql statement to run on the model/classname
string
Can be $this->baseclassname Returns an array of fields
boolean
boolean
selectFormattedNestedTree( $table)
selectNestedBranch( $table, null $node = null) : array
null
array
selectNestedNodeChildren( $table, null $node = null) : array
null
array
selectNestedNodeParent( $table, null $node = null) : array
null
array
selectNestedTree( $table) : array
array
selectObject(string $table, string $where) : object|null|void
Selects an objects from the database. Because of the way Exponent handles objects and database tables, this is akin to SELECTing a single record from a database table. Returns the first record/object found (in the case of multiple-result queries, there is no way to determine which of the set will be returned). If no record(s) match the query, null is returned.
string
The name of the table/object to look at
string
Criteria used to narrow the result set.
object|null|void
selectObjectBySql( $sql) : null|void
null|void
selectObjects(string $table, string $where = null, null $orderby = null, boolean $is_revisioned = false, boolean $needs_approval = false, null $user = null) : array
Selects a set of objects from the database. Because of the way Exponent handles objects and database tables, this is akin to SELECTing a set of records from a database table. Returns an array of objects, in any random order.
string
The name of the table/object to look at
string
Criteria used to narrow the result set. If this is specified as null, then no criteria is applied, and all objects are returned
null
boolean
boolean
null
array
selectObjectsBySql( $sql) : array
array
selectObjectsInArray( $table, array $array = array(), null $orderby = null) : array
array
null
array
selectObjectsIndexedArray(string $table, string $where = null, null $orderby = null) : array
Selects a set of objects from the database. Because of the way Exponent handles objects and database tables, this is akin to SELECTing a set of records from a database table. Returns an array of objects, in any random order. The indices of the array are the IDs of the objects.
string
The name of the table/object to look at
string
Criteria used to narrow the result set. If this is specified as null, then no criteria is applied, and all objects are returned
null
array
selectPathToNestedNode( $table, null $node = null) : array
null
array
selectSearch( $terms, null $where = null)
null
selectSum( $table, $col, null $where = null)
null
selectValue( $table, $col, null $where = null) : null
null
null
selectValueBySql( $sql) : null
null
setUniqueFlag( $object, $table, $col, integer|null $where = 1) : boolean
integer|null
boolean
sql(string $sql, boolean $escape = true) : mixed
Runs a straight SQL query on the database. This is not a very portable way of dealing with the database, and is only provided as a last resort.
string
The SQL query to run
boolean
mixed
sql_connect_pdo() : \PDO
\PDO
Database connection handle
switchValues( $table, $field, $a, $b, null $additional_where = null) : boolean
Switches values between two table entries for things like swapping rank, etc...
null
boolean
tableExists(string $table) : boolean
Returns true if the table exists, and false if it doesn't.
string
Name of the table to look for.
boolean
tableInfo( $table) : null
Returns an object, with the following attributes:
null
tableIsEmpty(string $table) : boolean
Returns tue of the specified table has no rows, and false if otherwise.
string
Name of the table to check.
boolean
testPrivileges() : array
Tests run include:
These tests must be performed in order, for logical reasons. Execution terminates when the first test fails, and the status flag array is returned then. Returns an array of status flags. Key is the test name. Value is a boolean, true if the test succeeded, and false if it failed.
array
toggle( $table, $col, null $where = null) : void
null
trim_revisions(string $table, integer $id, integer $num, integer|string $workflow = ENABLE_WORKFLOW)
string
The name of the table to trim
integer
The item id
integer
The number of revisions to retain
integer|string
is workflow turned on (or force)
unlockTables() : mixed
mixed
updateObject(object $object, string $table, string $where = null, string $identifier = 'id', boolean $is_revisioned = false) : boolean|integer|void
This function will only update the attributes of the resulting record(s) that are also member attributes of the $object object.
object
An object specifying the fields and values for updating. In most cases, this will be the altered object originally returned from one of the select* methods.
string
The table to update in.
string
Optional criteria used to narrow the result set.
string
boolean
boolean|integer|void
connection : string
var |
Database connection string |
---|
string
havedb : boolean
var |
---|
boolean
prefix : string
var |
Database prefix |
---|
string