Class: DBUtil
Source Location: /includes/pnobjlib/DBUtil.class.php
Class Details
Class Methods
method addColumn [line 2645]
void addColumn(
tablename
$tablename, fields
$fields)
|
|
add column(s) to a table
Tags:
Parameters:
method changeTable [line 2353]
bool changeTable(
tablename
$tablename, [sql
$sql = null], [tabopt
$tabopt = null])
|
|
change database table using ADODB dictionary method
Tags:
Parameters:
method createDatabase [line 2946]
bool createDatabase(
dbname
$dbname, [optionsarray
$optionsarray = false])
|
|
create database
Tags:
Parameters:
method createIndex [line 2510]
void createIndex(
idxname
$idxname, tablename
$tablename, flds
$flds, [idxoptarray
$idxoptarray = false])
|
|
create index on table
Tags:
Parameters:
method createTable [line 2302]
bool createTable(
tablename
$tablename, [sql
$sql = null], [tabopt
$tabopt = null])
|
|
create a database table using ADODB dictionary method
Tags:
Parameters:
method decrementObjectFieldByID [line 2041]
The decrementObjectFieldByID(
tablename
$tablename, decfield
$decfield, id
$id, [idfield
$idfield = 'id'], [deccount
$deccount = 1])
|
|
Loop through the array and feed it to DBUtil::insertObject()
Tags:
Parameters:
method deleteObject [line 2093]
The deleteObject(
object The
$object, tablename
$tablename, [where
$where = ''], [idcolumn
$idcolumn = 'id'])
|
|
Generate and execute a delete SQL statement for the given object
Tags:
Parameters:
method deleteObjectByID [line 2075]
The deleteObjectByID(
tablename
$tablename, id
$id, [idcolumn
$idcolumn = 'id'])
|
|
Delete an object by its ID.
Tags:
Parameters:
method deleteObjectsFromKeyArray [line 2185]
void deleteObjectsFromKeyArray(
$keyarray,
$tablename, [
$field = 'id'])
|
|
Parameters:
method deleteWhere [line 2055]
The deleteWhere(
tablename
$tablename, where
$where)
|
|
Delete (an) object(s) via a where clause
Tags:
Parameters:
method dropColumn [line 2685]
void dropColumn(
tablename
$tablename, fields
$fields)
|
|
drop column(s) from a table
Tags:
Parameters:
method dropIndex [line 2572]
void dropIndex(
idxname
$idxname, tablename
$tablename)
|
|
drop index on table
Tags:
Parameters:
method dropTable [line 2464]
bool dropTable(
tablename
$tablename)
|
|
delete database table
Parameters:
method executeSQL [line 56]
mixed executeSQL(
sql
$sql, [limitOffset
$limitOffset = -1], [limitNumRows
$limitNumRows = -1], [sql
$exitOnError = true], [exitOnError
$verbose = true], verbose
5)
|
|
Execute SQL, check for errors and return result. Uses Adodb to generate DB-portable paging code.
Tags:
Parameters:
method generateCategoryFilterWhere [line 804]
The generateCategoryFilterWhere(
tablename
$tablename, where
$where, categoryFilter
$categoryFilter, [returnArray
$returnArray = false], [usesJoin
$usesJoin = false])
|
|
Append the approriate category filter where-clause to the given where clause.
Tags:
Parameters:
method getColumnsArray [line 458]
The getColumnsArray(
tablename
$tablename, [columnArray
$columnArray = null])
|
|
return the column array for the given table
Tags:
Parameters:
method getInsertID [line 2209]
void getInsertID(
$tablename, [
$field = 'id'], [
$exitOnError = true], [
$verbose = true])
|
|
Parameters:
method getLimitedTablename [line 2973]
bool getLimitedTablename(
$tablename
$tablename, [$dbdriver
$dbdriver = ''])
|
|
limit the table name if necessary and prepend the prefix When using Oracle the object name may not be longer than 30 chars. Now ADODB uses TRIGGERS and SEQUENCEs to emulate the AUTOINCREMENT which eats up to 9 chars (TRIG_SEQ_<prefix>_<tablename>) so we have to limit the length of the table name to 30 - 9 - length(prefix) - separator. We use this function as a central point to shorten table name (there might be restrictions in ' other RDBMS too). If the resulting tablename is empty we will show an error. In this case the prefix is too long.
Tags:
Parameters:
method getTableConstraints [line 2272]
void getTableConstraints(
$tablename)
|
|
get the table constraints from the pntables array
Tags:
Parameters:
method getTableDefinition [line 2233]
void getTableDefinition(
$tablename)
|
|
get the table definition from the pntables array
Parameters:
method incrementObjectFieldByID [line 2013]
The incrementObjectFieldByID(
tablename
$tablename, incfield
$incfield, id
$id, [idfield
$idfield = 'id'], [inccount
$inccount = 1])
|
|
Increment a field by the given increment
Tags:
Parameters:
method insertObject [line 1708]
The insertObject(
object The
&$object, tablename
$tablename, [idcolumn
$idcolumn = 'id'], [preserve
$preserve = false], [force
$force = false])
|
|
Generate and execute an insert SQL statement for the given object
Tags:
Parameters:
method insertObjectArray [line 1678]
The insertObjectArray(
objects
&$objects, tablename
$tablename, [idcolumn
$idcolumn = 'id'], [preserve
$preserve = false], [force
$force = false])
|
|
Loop through the array and feed it to DBUtil::insertObject()
Tags:
Parameters:
method marshallFieldArray [line 667]
The marshallFieldArray(
result
$result, [closeResultSet
$closeResultSet = true], [assocKey
$assocKey = ''], [
$clean = true])
|
|
Transform a result set into an array of field values
Tags:
Parameters:
method marshallObjects [line 500]
The marshallObjects(
result
$result, objectColumns
$objectColumns, [closeResultSet
$closeResultSet = true], [assocKey
$assocKey = ''], [clean
$clean = true], [permissionFilter
$permissionFilter = null], [tablename
$tablename = null])
|
|
Transform a SQL query result set into an object/array, optionally applying an PN permission filter
Tags:
Parameters:
method metaColumnNames [line 2848]
void metaColumnNames(
tablename
$tablename, [numericIndex
$numericIndex = false])
|
|
get a list of column names in a table
Tags:
Parameters:
method metaColumns [line 2747]
void metaColumns(
tablename
$tablename, [notcasesensitive
$assoc = false], [
$notcasesensitive = true])
|
|
get a list of columns in a table
Tags:
Parameters:
method metaColumnType [line 2781]
void metaColumnType(
tablename
$tablename, column
$column, [showAutoIncrement
$showAutoIncrement = false], [showDefault
$showDefault = false])
|
|
get a the ADODB meta-type for a table column
Tags:
Parameters:
method metaDatabases [line 2716]
get a list of databases available on the server
Tags:
method metaForeignKeys [line 2891]
void metaForeignKeys(
tablename
$tablename, [owner
$owner = false], [upper
$upper = false])
|
|
get a list of foreign keys for a table
Tags:
Parameters:
method metaIndexes [line 2913]
void metaIndexes(
table
$tablename, [primary
$primary = false], [owner
$owner = false])
|
|
get a list of indexes for a table
Tags:
Parameters:
method metaPrimaryKeys [line 2869]
void metaPrimaryKeys(
tablename
$tablename, [owner
$owner = false])
|
|
get a list of primary keys for a table
Tags:
Parameters:
method metaTables [line 2732]
void metaTables(
[ttype
$ttype = false], [showSchema
$showSchema = false], [mask
$mask = false])
|
|
get a list of tables in the currently connected database
Tags:
Parameters:
method objectCache [line 1291]
void &objectCache(
[bool
$clear = false], [string
$tablename = null])
|
|
Object cache interface Call without parameters to fetch cache. Call with $clear=true to clear the cache (optionally only for one specific table).
Parameters:
method renameColumn [line 2606]
void renameColumn(
tablename
$tablename, oldcolumn
$oldcolumn, newcolumn
$newcolumn, [fields
$fields = null])
|
|
rename column(s) in a table
Tags:
Parameters:
method renameTable [line 2434]
bool renameTable(
tablename
$tablename,
$newtablename)
|
|
rename database table
Parameters:
method selectExpandedFieldArray [line 893]
The selectExpandedFieldArray(
tablename
$tablename, joinInfo
$joinInfo, field
$field, [where
$where = ''], [orderby
$orderby = ''], [distinct
$distinct = false], [assocKey
$assocKey = ''], [permissionFilter
$permissionFilter = null])
|
|
Select & return an expanded field array
Tags:
Parameters:
method selectExpandedObject [line 1403]
The selectExpandedObject(
tablename
$tablename, joinInfo
$joinInfo, [where
$where = ''], [columnArray
$columnArray = null], [permissionFilter
$permissionFilter = null], [categoryFilter
$categoryFilter = null])
|
|
Select & return a object with it's left join fields filled in
Tags:
Parameters:
method selectExpandedObjectArray [line 1608]
The selectExpandedObjectArray(
tablename
$tablename, joinInfo
$joinInfo, [where
$where = ''], [orderby
$orderby = ''], [limitOffset
$limitOffset = -1], [limitNumRows
$limitNumRows = -1], [assocKey
$assocKey = ''], [permissionFilter
$permissionFilter = null], [columnArray
$categoryFilter = null], [
$columnArray = null])
|
|
Select & return an array of objects with it's left join fields filled in
Tags:
Parameters:
method selectExpandedObjectByID [line 1431]
The selectExpandedObjectByID(
tablename
$tablename, joinInfo
$joinInfo, id
$id, [field
$field = 'id'], [columnArray
$columnArray = null], [permissionFilter
$permissionFilter = null], [categoryFilter
$categoryFilter = null], [transformFunc
$transformFunc = null])
|
|
Select & return an object by it's ID with it's left join fields filled in
Tags:
Parameters:
method selectExpandedObjectCount [line 1213]
The selectExpandedObjectCount(
tablename
$tablename, joinInfo
$joinInfo, [where
$where = ''], [distinct
$distinct = false], [categoryFilter
$categoryFilter = null])
|
|
Return the number of rows affected
Tags:
Parameters:
method selectField [line 1029]
The selectField(
tablename
$tablename, field
$field, [where
$where = ''])
|
|
Select & return a field
Tags:
Parameters:
method selectFieldArray [line 834]
The selectFieldArray(
tablename
$tablename, field
$field, [where
$where = ''], [orderby
$orderby = ''], [distinct
$distinct = false], [assocKey
$assocKey = ''])
|
|
Select & return a field array
Tags:
Parameters:
method selectFieldArrayByID [line 869]
The selectFieldArrayByID(
tablename
$tablename, field
$field, id
$id, [idfield
$idfield = 'id'])
|
|
Select & return an array of field by an ID-field value
Tags:
Parameters:
method selectFieldByID [line 1010]
The selectFieldByID(
tablename
$tablename, field
$field, id
$id, [idfield
$idfield = 'id'])
|
|
Select & return a field by an ID-field value
Tags:
Parameters:
method selectFieldMax [line 934]
The selectFieldMax(
tablename
$tablename, field
$field, [option
$option = 'MAX'], [where
$where = ''])
|
|
Select & return the max/min value of a field
Tags:
Parameters:
method selectFieldMaxArray [line 970]
The selectFieldMaxArray(
tablename
$tablename, field
$field, [option
$option = 'MAX'], [where
$where = ''], [assocKey
$assocKey = ''])
|
|
Select & return the max/min array of a field grouped by the associated key
Tags:
Parameters:
method selectObject [line 1112]
The selectObject(
tablename
$tablename, [where
$where = ''], [columnArray
$columnArray = null], [permissionFilter
$permissionFilter = null], [categoryFilter
$categoryFilter = null], [
$cacheObject = true])
|
|
Select & return a specific object based on a PN table definition
Tags:
Parameters:
method selectObjectArray [line 1463]
The selectObjectArray(
tablename
$tablename, [where
$where = ''], [orderby
$orderby = ''], [limitOffset
$limitOffset = -1], [limitNumRows
$limitNumRows = -1], [assocKey
$assocKey = ''], [permissionFilter
$permissionFilter = null], [categoryFilter
$categoryFilter = null], [columnArray
$columnArray = null])
|
|
Select & return an object array based on a PN table definition
Tags:
Parameters:
method selectObjectArrayFilter [line 1544]
The selectObjectArrayFilter(
tablename
$tablename, [where
$where = ''], [orderby
$orderby = ''], [limitOffset
$limitOffset = -1], [limitNumRows
$limitNumRows = -1], [assocKey
$assocKey = ''], filterCallback
$filterCallback, [columnArray
$categoryFilter = null], [
$columnArray = null])
|
|
Select & return an object array based on a PN table definition The result is filtered by a callback object passed into the function. This object must have implemented a method called "checkResult" which is passed the resulting data rows one by one. The "checkResult" function returns true if the datarow is ok, otherwise it returns false. Example: class myFilter
{
var $userId;
function checkResult($datarow)
{
return $datarow['ownerUserId'] == $this->userId;
}
}
Tags:
Parameters:
method selectObjectByID [line 1324]
The selectObjectByID(
tablename
$tablename, id
$id, [field
$field = 'id'], [columnArray
$columnArray = null], [permissionFilter
$permissionFilter = null], [categoryFilter
$categoryFilter = null], [cacheObject
$cacheObject = true], [transformFunc
$transformFunc = null])
|
|
Select & return a specific object by using the ID field
Tags:
Parameters:
method selectObjectCount [line 1143]
The selectObjectCount(
tablename
$tablename, [where
$where = ''], [column
$column = '1'], [distinct
$distinct = false], [categoryFilter
$categoryFilter = null])
|
|
Return the number of rows affected
Tags:
Parameters:
method selectObjectCountByID [line 1180]
The selectObjectCountByID(
tablename
$tablename, id
$id, [field
$field = 'id'], [transformFunc
$transformFunc = ''])
|
|
Select an object count by ID
Tags:
Parameters:
method selectObjectSQL [line 1069]
The selectObjectSQL(
sql
$sql, tablename
$tablename, [columnArray
$columnArray = null], [permissionFilter
$permissionFilter = null], [
$cacheObject = true])
|
|
Select & return a specific object using the given sql statement
Tags:
Parameters:
method selectObjectSum [line 1257]
The selectObjectSum(
tablename
$tablename, column
$column, [where
$where = ''], [categoryFilter
$categoryFilter = null])
|
|
Return the sum of a column
Tags:
Parameters:
method selectScalar [line 1366]
mixed selectScalar(
$sql, [
$exitOnError = true])
|
|
Execute SQL select statement and return the value of the first column in the first row Mostly usefull for places where you want to do a "select count(*)" or similar scalar selection.
Tags:
Parameters:
method serverInfo [line 2931]
return server information
Tags:
method SQLCache [line 1047]
void &SQLCache(
[bool
$clear = false])
|
|
SQL cache interface Call without parameters to fetch cache. Call with $clear=true to clear the cache.
Parameters:
method truncateTable [line 2411]
bool truncateTable(
tablename
$tablename)
|
|
truncate database table
Parameters:
method updateObject [line 1866]
The updateObject(
object The
&$object, tablename
$tablename, [where
$where = ''], [idcolumn
$idcolumn = 'id'], [force
$force = false], [updateid
$updateid = false])
|
|
Generate and execute an update SQL statement for the given object
Tags:
Parameters:
method updateObjectArray [line 1985]
The updateObjectArray(
objects
&$objects, tablename
$tablename, [idcolumn
$idcolumn = 'id'], [force
$force = false])
|
|
Loop through the array and feed it to DBUtil::updateObject()
Tags:
Parameters:
method _addMarshalledObjectCount [line 191]
Nothing, _addMarshalledObjectCount(
count
$count)
|
|
Add the specified value to the gobal object marshall counter This function is workaround for PHP4 limitations when passing default arguments by reference
Tags:
Parameters:
method _checkOrderByClause [line 244]
The _checkOrderByClause(
orderby
$orderby, [tablename
$tablename = null])
|
|
Convenience function to ensure that the order-by-clause starts with "ORDER BY"
Tags:
Parameters:
method _checkOrderByField [line 310]
string _checkOrderByField(
[field
$tablename = ''], [
$field = ''])
|
|
Convenience function to ensure that the field to be used as ORDER BY is not a CLOB/BLOB when using Oracle
Tags:
Parameters:
method _checkWhereClause [line 220]
The _checkWhereClause(
where
$where)
|
|
Convenience function to ensure that the where-clause starts with "WHERE"
Tags:
Parameters:
method _formatForStore [line 437]
string _formatForStore(
@value
$value)
|
|
Format value for use in SQL statement Special handling for integers and booleans (the last is required for MySQL 5 strict mode)
Tags:
Parameters:
method _generateCategoryFilter [line 740]
The _generateCategoryFilter(
categoryFilter
$tablename, returnArray
$categoryFilter, [
$returnArray = false])
|
|
Build a list of objects which are mapped to the specified categories
Tags:
Parameters:
method _getAllColumns [line 372]
The _getAllColumns(
tablename
$tablename, [columnArray
$columnArray = null])
|
|
Same as PN Api function but without AS aliasing
Tags:
Parameters:
method _getAllColumnsQualified [line 406]
The _getAllColumnsQualified(
tablename
$tablename, tablealias
$tablealias, [columnArray
$columnArray = null])
|
|
Same as PN Api function but returns fully qualified fieldnames
Tags:
Parameters:
method _getFetchedObjectCount [line 157]
The _getFetchedObjectCount(
)
|
|
Get the gobal object fetch counter This function is workaround for PHP4 limitations when passing default arguments by reference
Tags:
method _getMarshalledObjectCount [line 204]
Nothing, _getMarshalledObjectCount(
)
|
|
Get the gobal object marshall counter This function is workaround for PHP4 limitations when passing default arguments by reference
Tags:
method _getSelectAllColumnsFrom [line 345]
Nothing, _getSelectAllColumnsFrom(
tablename
$tablename, [where
$where = ''], [orderBy
$orderBy = ''], [columnArray
$columnArray = null])
|
|
Build a basic select clause for the specified table with the specified where and orderBy clause
Tags:
Parameters:
method _handleClobFields [line 3020]
the _handleClobFields(
clobArray
$tablename, tablename
$object, idcolumn
$clobArray,
$idcolumn)
|
|
Handle any CLOB fields which were contained in an insert or update query. This method loops through the clob fields and updates them one at a time.
Tags:
Parameters:
method _processJoinArray [line 3067]
array _processJoinArray(
tablename
$tablename, joinInfo
$joinInfo, [columnArray
$columnArray = null])
|
|
This method creates the necessary sql information for retrieving fields from joined tables defined by a joinInfo array described at the top of this class.
Tags:
Parameters:
method _savePostProcess [line 3222]
the _savePostProcess(
object the
$object, tablename
$tablename, idcolumn
$idcolumn, [update
$update = false])
|
|
Post-processing after this object has beens saved. This routine is responsible for writing the 'extra' data (attributes, categories, and meta data) to the database and the optionally creating an entry in the object-log table
Tags:
Parameters:
method _selectPostProcess [line 3139]
the _selectPostProcess(
objects
$objects, tablename
$tablename, idcolumn
$idcolumn)
|
|
Post-processing after this object has been selected. This routine is responsible for reading the 'extra' data (attributes, categories, and meta data) from the database and inserting the relevant sub-objects into the object.
Tags:
Parameters:
method _setFetchedObjectCount [line 144]
Nothing, _setFetchedObjectCount(
[count
$count = 0])
|
|
Set the gobal object fetch counter to the specified value This function is workaround for PHP4 limitations when passing default arguments by reference
Tags:
Parameters:
method _setMarshalledObjectCount [line 176]
Nothing, _setMarshalledObjectCount(
[count
$count = 0])
|
|
Set the gobal object marshall counter to the specified value This function is workaround for PHP4 limitations when passing default arguments by reference
Tags:
Parameters:
|
|