This is the abstract class database
This is the generic implementation of the database class.
| define |
"BASE" "../.." |
|---|---|
| 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.
stringThe name of the table to alter
arrayThe new data definition for the table. This is expressed in the Exponent Data Definition Language
arrayInformation about the table itself.
booleanWhether 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
stringThe name of the table to count objects in.
stringCriteria for counting.
boolean
boolean
null
integer
countObjectsBySql(string $sql) : integer
stringThe 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.
stringThe name of the table to create
arrayThe data definition to create, expressed in the Exponent Data Definition Language.
arrayInformation 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)
stringThe name of the table to decrement in.
stringThe field to decrement.
integerThe step value. Usually 1. This can be negative, to increment, but the increment() method is preferred, for readability.
stringOptional criteria to determine which records to update.
delete(string $table, string $where = null) : mixed
stringThe name of the table to delete from.
stringCriteria 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.
stringThe name of the table to drop.
boolean
error() : string
string
escapeString( $string) : string
string
fieldSQL( $name, $def)
getDataDefinition(string $table) : array|null
stringThe name of the table to get a data definition for.
array|null
getDDFieldType( $fieldObj)
getDDStringLen( $fieldObj)
getTables(boolean $prefixed_only = true) : array
booleanWhether 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
stringThe name of the table to increment in.
stringThe field to increment.
integerThe step value. Usually 1. This can be negative, to decrement, but the decrement() method is preferred, for readability.
stringOptional 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.
objectThe object to insert.
stringThe logical table name to insert into. This does not include the table prefix, which is automagically prepended for you.
integer|void
isValid() : boolean
booleanTrue 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.
stringThe name of the table to select from.
stringThe attribute name to find a maximum value for.
stringA 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.
stringOptional criteria for narrowing the result set.
mixed
min( $table, $attribute, $groupfields = null, $where = null)
optimize(string $table) : boolean
stringThe name of the table to optimize.
boolean
queryRows(string $sql) : integer|void
stringThe 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
stringThe name of the table/object to look at
stringCriteria 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.
stringThe name of the table/object to look at
stringCriteria 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.
stringThe 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
stringThe name of the table/object to look at
stringCriteria 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)
stringThe sql statement to run on the model/classname
stringCan 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.
stringThe name of the table/object to look at
stringCriteria 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.
stringThe name of the table/object to look at
stringCriteria 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.
stringThe name of the table/object to look at
stringCriteria 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.
stringThe SQL query to run
boolean
mixed
sql_connect_pdo() : \PDO
\PDODatabase 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.
stringName 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.
stringName 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
translateTableStatus( $status)
trim_revisions(string $table, integer $id, integer $num, integer|string $workflow = ENABLE_WORKFLOW)
stringThe name of the table to trim
integerThe item id
integerThe number of revisions to retain
integer|stringis 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.
objectAn 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.
stringThe table to update in.
stringOptional criteria used to narrow the result set.
string
boolean
boolean|integer|void
error :
in_error :
connection : string
| var |
Database connection string |
|---|
string
havedb : boolean
| var |
|---|
boolean
prefix : string
| var |
Database prefix |
|---|
string