kernel
[ class tree: kernel ] [ index: kernel ] [ all elements ]

Class: BitDbAdodb

Source Location: /kernel/BitDbAdodb.php

Class Overview

BitDb
   |
   --BitDbAdodb

This class is used for database access and provides a number of functions to help with database portability.


Methods


Inherited Variables

Inherited Methods

Class: BitDb

BitDb::BitDb()
During initialisation, database parameters are passed to the class.
BitDb::Affected_Rows()
BitDb::associateInsert()
This function will take a set of fields identified by an associative array - $insertData
BitDb::associateUpdate()
This function will take a set of fields identified by an associative array - $updateData
BitDb::CompleteTrans()
Used together with StartTrans() to end a transaction. Monitors connection for sql errors, and will commit or rollback as appropriate.
BitDb::convertBinary()
Returns the keyword to force a column comparison to be case sensitive
BitDb::convertQuery()
Converts backtick (`) quotes to the appropriate quote for the database.
BitDb::convertSortmode()
Converts field sorting abbreviation to SQL - you can pass in a single string or an entire array of sortmodes
BitDb::convertSortmodeOneItem()
Converts field sorting abbreviation to SQL and it also allows us to do things like sort by random rows.
BitDb::convert_binary()
BitDb::convert_sortmode()
BitDb::convert_sortmode_one_item()
BitDb::CreateSequence()
A database portable Sequence management function.
BitDb::createTables()
Used to create tables - most commonly from package/schema_inc.php files
BitDb::dbByteDecode()
Used to decode blob data (eg PostgreSQL)
BitDb::dbByteEncode()
Used to encode blob data (eg PostgreSQL). Can be called statically
BitDb::db_byte_decode()
BitDb::db_byte_encode()
BitDb::debug()
will activate ADODB like native debugging output
BitDb::depText()
BitDb::dropTables()
Used to drop tables
BitDb::Execute()
ADODB compatibility functions for bitcommerce
BitDb::GenID()
A database portable Sequence management function.
BitDb::getArray()
Returns an associative array for the given query.
BitDb::getAssoc()
Returns an associative array for the given query.
BitDb::getCaselessColumn()
Compatibility function for DBs with case insensitive searches
BitDb::getCaseSensitivity()
Sets the case sensitivity mode which is used in convertQuery
BitDb::getCol()
Executes the SQL and returns all elements of the first column as a 1-dimensional array. The recordset is discarded for you automatically. If an error occurs, false is returned.
BitDb::getDatabaseVersion()
determine current version of the databse
BitDb::getDebugLevel()
returns the level of query debugging output
BitDb::getOne()
Returns a single column value from the database.
BitDb::getPeriodFormat()
BitDb::getRow()
Executes the SQL and returns the first row as an array. The recordset and remaining rows are discarded for you automatically. If an error occurs, false is returned.
BitDb::ifNull()
A database portable IFNULL function.
BitDb::isAdvancedPostgresEnabled()
Check for Postgres specific extensions
BitDb::isCachingActive()
Function to set ADODB query caching member variable
BitDb::isFatalActive()
Determines if the database connection is valid
BitDb::isValid()
Determines if the database connection is valid
BitDb::ls()
Format the timestamp in the format the database accepts.
BitDb::MetaColumns()
List columns in a database as an array of ADOFieldObjects.
BitDb::MetaIndexes()
List indexes in a database as an array of ADOFieldObjects.
BitDb::MetaTables()
Create a list of tables available in the current database
BitDb::NOW()
Return the current timestamp literal relevent to the database type
BitDb::OffsetDate()
Calculate the offset of a date for a particular database and generate appropriate SQL. Useful for calculating future/past dates and storing in a database.
BitDb::postDBConnection()
This function contains any post-connection work
BitDb::preDBConnection()
This function contains any pre-connection work
BitDb::qstr()
Quotes a string to be sent to the database
BitDb::qtNOW()
Return the current timestamp literal relevent to the database type
BitDb::query()
Queries the database reporting an error if detected
BitDb::queryComplete()
Used to stop query tracking and output results if in debug mode
BitDb::queryError()
Queries the database, returning an error if one occurs, rather
BitDb::queryStart()
Used to start query timer if in debug mode
BitDb::random()
A database portable RANDOM() function.
BitDb::RollbackTrans()
If database does not support transactions, rollbacks always fail, so return false otherwise returns true if the Rollback was successful
BitDb::setCaching()
Function to set ADODB query caching member variable
BitDb::setCaseSensitivity()
Sets the case sensitivity mode which is used in convertQuery
BitDb::setFatalActive()
Determines if the database connection is valid
BitDb::sqlCast()
Used to cast variable types for certain databases (ie SyBase & MSSQL)
BitDb::SQLDate()
Format date column in sql string given an input format that understands Y M D
BitDb::SQLForUpdate()
Return the sql to lock selected rows for updating.
BitDb::SQLIntToTimestamp()
Return the sql to cast the given column from an long integer to a time stamp.
BitDb::SQLTimestampToInt()
Return the sql to cast the given column from a time stamp to a Unix epoch
BitDb::sql_cast()
BitDb::StartTrans()
Improved method of initiating a transaction. Used together with CompleteTrans().
BitDb::tableExists()
Used to check if tables already exists.

Class Details

[line 39]
This class is used for database access and provides a number of functions to help with database portability.

Currently used as a base class, this class should be optional to ensure bitweaver continues to function correctly, without a valid database connection.




[ Top ]


Class Methods


constructor BitDbAdodb [line 40]

BitDbAdodb BitDbAdodb( [ $pConnectionHash = NULL])



Parameters:

   $pConnectionHash  

[ Top ]

method Affected_Rows [line 632]

# Affected_Rows( )



Tags:

return:  rows affected by UPDATE/DELETE


Overrides BitDb::Affected_Rows() (parent method not documented)

[ Top ]

method CompleteTrans [line 598]

TRUE CompleteTrans( )

Used together with StartTrans() to end a transaction. Monitors connection for sql errors, and will commit or rollback as appropriate.

autoComplete if TRUE, monitor sql errors and commit and rollback as appropriate, and if set to FALSE force rollback even if no SQL error detected.




Tags:

return:  on commit, FALSE on rollback.


Overrides BitDb::CompleteTrans() (Used together with StartTrans() to end a transaction. Monitors connection for sql errors, and will commit or rollback as appropriate.)

[ Top ]

method convertQuery [line 541]

the convertQuery( pQuery &$pQuery)

Converts backtick (`) quotes to the appropriate quote for the database.



Tags:

return:  correctly quoted SQL statement
todo:  investigate replacement by AdoDB NameQuote() function
private:  


Overrides BitDb::convertQuery() (Converts backtick (`) quotes to the appropriate quote for the database.)

Parameters:

pQuery   &$pQuery   the SQL query using backticks (`)

[ Top ]

method CreateSequence [line 464]

0 CreateSequence( [pSequenceName $pSeqname = 'adodbseq'], [pStartID $startID = 1])

A database portable Sequence management function.



Tags:

return:  if not supported, otherwise a sequence id
todo:  To be combined with GenID


Overrides BitDb::CreateSequence() (A database portable Sequence management function.)

Parameters:

pSequenceName   $pSeqname   Name of the sequence to be used It will be created if it does not already exist
pStartID   $startID   Allows setting the initial value of the sequence

[ Top ]

method createTables [line 97]

TRUE|FALSE createTables( pTables $pTables, [pOptions $pOptions = array()])

Used to create tables - most commonly from package/schema_inc.php files



Tags:

return:  TRUE if created with no errors | FALSE if errors are stored in $this->mFailed
todo:  remove references to BIT_DB_PREFIX, us a member function


Overrides BitDb::createTables() (Used to create tables - most commonly from package/schema_inc.php files)

Parameters:

pTables   $pTables   an array of tables and creation information in DataDict style
pOptions   $pOptions   an array of options used while creating the tables

[ Top ]

method debug [line 562]

void debug( [pLevel $pLevel = 99])

will activate ADODB's native debugging output



Overrides BitDb::debug() (will activate ADODB like native debugging output)

Parameters:

pLevel   $pLevel   debugging level - FALSE is off, TRUE is on, 99 is verbose

[ Top ]

method DropSequence [line 478]

FALSE DropSequence( [pSequenceName $pSeqname = 'adodbseq'])

A database portable Sequence management function.



Tags:

return:  if not supported


Parameters:

pSequenceName   $pSeqname   Name of the sequence to be dropped

[ Top ]

method dropTables [line 144]

TRUE dropTables( pTables $pTables)

Used to drop tables



Tags:

return:  | FALSE TRUE if dropped with no errors | FALSE if errors are stored in $this->mFailed
todo:  remove references to BIT_DB_PREFIX, us a member function


Overrides BitDb::dropTables() (Used to drop tables)

Parameters:

pTables   $pTables   an array of table names to drop

[ Top ]

method GenID [line 443]

0 GenID( pSequenceName $pSequenceName, [ $pUseDbPrefix = TRUE])

A database portable Sequence management function.



Tags:

return:  if not supported, otherwise a sequence id


Overrides BitDb::GenID() (A database portable Sequence management function.)

Parameters:

pSequenceName   $pSequenceName   Name of the sequence to be used It will be created if it does not already exist
   $pUseDbPrefix  

[ Top ]

method getAll [line 304]

TRUE getAll( string $pQuery, [array $pValues = FALSE], [numeric $pCacheTime = BIT_QUERY_DEFAULT])

getAll



Tags:

return:  on success, FALSE on failure - mErrors will contain reason for failure
access:  public


Parameters:

string   $pQuery  
array   $pValues  
numeric   $pCacheTime  

[ Top ]

method getArray [line 355]

the getArray( pQuery $pQuery, [pValues $pValues = FALSE], [pForceArray $pForceArray = FALSE], [pFirst2Cols $pFirst2Cols = FALSE], [ $pCacheTime = BIT_QUERY_DEFAULT])

Returns an associative array for the given query.

See AdoDB GetAssoc() function for more detail.




Tags:

return:  associative array, or FALSE if an error occurs


Overrides BitDb::getArray() (Returns an associative array for the given query.)

Parameters:

pQuery   $pQuery   the SQL query. Use backticks (`) to quote all table and attribute names for AdoDB to quote appropriately.
pValues   $pValues   an array of values used in a parameterised query
pForceArray   $pForceArray   if set to TRUE, when an array is created for each value
pFirst2Cols   $pFirst2Cols   if set to TRUE, only returns the first two columns
   $pCacheTime  

[ Top ]

method getAssoc [line 379]

the getAssoc( pQuery $pQuery, [pValues $pValues = FALSE], [pForceArray $pForceArray = FALSE], [pFirst2Cols $pFirst2Cols = FALSE], [ $pCacheTime = BIT_QUERY_DEFAULT])

Returns an associative array for the given query.

See AdoDB GetAssoc() function for more detail.




Tags:

return:  associative array, or FALSE if an error occurs


Overrides BitDb::getAssoc() (Returns an associative array for the given query.)

Parameters:

pQuery   $pQuery   the SQL query. Use backticks (`) to quote all table and attribute names for AdoDB to quote appropriately.
pValues   $pValues   an array of values used in a parameterised query
pForceArray   $pForceArray   if set to TRUE, when an array is created for each value
pFirst2Cols   $pFirst2Cols   if set to TRUE, only returns the first two columns
   $pCacheTime  

[ Top ]

method getCol [line 330]

the getCol( pQuery $pQuery, [pValues $pValues = FALSE], [pForceArray $pTrim = FALSE], [pFirst2Cols $pCacheTime = BIT_QUERY_DEFAULT])

Executes the SQL and returns all elements of the first column as a 1-dimensional array. The recordset is discarded for you automatically. If an error occurs, FALSE is returned.

See AdoDB GetCol() function for more detail.




Tags:

return:  associative array, or FALSE if an error occurs
todo:  not currently used anywhere


Overrides BitDb::getCol() (Executes the SQL and returns all elements of the first column as a 1-dimensional array. The recordset is discarded for you automatically. If an error occurs, false is returned.)

Parameters:

pQuery   $pQuery   the SQL query. Use backticks (`) to quote all table and attribute names for AdoDB to quote appropriately.
pValues   $pValues   an array of values used in a parameterised query
pForceArray   $pTrim   if set to TRUE, when an array is created for each value
pFirst2Cols   $pCacheTime   if set to TRUE, only returns the first two columns

[ Top ]

method getDebugLevel [line 572]

pLevel getDebugLevel( )

returns the level of query debugging output



Tags:

return:  debugging level - FALSE is off, TRUE is on, 99 is verbose


Overrides BitDb::getDebugLevel() (returns the level of query debugging output)

[ Top ]

method getOne [line 424]

the getOne( pQuery $pQuery, [pValues $pValues = NULL], [pReportErrors $pNumRows = NULL], [pOffset $pOffset = NULL], [ $pCacheTime = BIT_QUERY_DEFAULT])

Returns a single column value from the database.



Tags:

return:  associative array, or FALSE if an error occurs


Overrides BitDb::getOne() (Returns a single column value from the database.)

Parameters:

pQuery   $pQuery   the SQL query. Use backticks (`) to quote all table and attribute names for AdoDB to quote appropriately.
pValues   $pValues   an array of values used in a parameterised query
pReportErrors   $pNumRows   report errors to STDOUT
pOffset   $pOffset   the row number to begin returning rows from.
   $pCacheTime  

[ Top ]

method getRow [line 401]

returns getRow( pQuery $pQuery, [pValues $pValues = FALSE], [ $pCacheTime = BIT_QUERY_DEFAULT])

Executes the SQL and returns the first row as an array. The recordset and remaining rows are discarded for you automatically. If an error occurs, FALSE is returned.

See AdoDB GetRow() function for more detail.




Tags:

return:  the first row as an array, or FALSE if an error occurs


Overrides BitDb::getRow() (Executes the SQL and returns the first row as an array. The recordset and remaining rows are discarded for you automatically. If an error occurs, false is returned.)

Parameters:

pQuery   $pQuery   the SQL query. Use backticks (`) to quote all table and attribute names for AdoDB to quote appropriately.
pValues   $pValues   an array of values used in a parameterised query
   $pCacheTime  

[ Top ]

method ifNull [line 494]

a ifNull( pField $pField, pNullRepl $pNullRepl)

A database portable IFNULL function.



Tags:

return:  string that represents the function that checks whether $pField is NULL for the given database, and if NULL, change the value returned to $pNullRepl.


Overrides BitDb::ifNull() (A database portable IFNULL function.)

Parameters:

pField   $pField   argument to compare to NULL
pNullRepl   $pNullRepl   the NULL replacement value

[ Top ]

method ls [line 504]

the ls( pDate $pDate)

Format the timestamp in the format the database accepts.



Tags:

return:  timestamp as a quoted string.
todo:  could be used to later convert all int timestamps into db timestamps. Currently not used anywhere.


Overrides BitDb::ls() (Format the timestamp in the format the database accepts.)

Parameters:

pDate   $pDate   a Unix integer timestamp or an ISO format Y-m-d H:i:s

[ Top ]

method MetaColumns [line 275]

array MetaColumns( table $table, [upper $normalize = TRUE], [schema $schema = FALSE])

List columns in a database as an array of ADOFieldObjects.

See top of file for definition of object.




Tags:

return:  of ADOFieldObjects for current table.


Overrides BitDb::MetaColumns() (List columns in a database as an array of ADOFieldObjects.)

Parameters:

table   $table   table name to query
upper   $normalize   uppercase table name (required by some databases)
schema   $schema   is optional database schema to use - not supported by all databases.

[ Top ]

method MetaIndexes [line 290]

array MetaIndexes( table $table, [primary $primary = FALSE], [owner $owner = FALSE])

List indexes in a database as an array of ADOFieldObjects.

See top of file for definition of object.




Tags:

return:  of ADOFieldObjects for current table.


Overrides BitDb::MetaIndexes() (List indexes in a database as an array of ADOFieldObjects.)

Parameters:

table   $table   table name to query
primary   $primary   list primary indexes
owner   $owner   list owner of index

[ Top ]

method MetaTables [line 625]

array MetaTables( [ttype $ttype = FALSE], [showSchema $showSchema = FALSE], [mask $mask = FALSE])

Create a list of tables available in the current database



Tags:

return:  of tables for current database.


Overrides BitDb::MetaTables() (Create a list of tables available in the current database)

Parameters:

ttype   $ttype   can either be 'VIEW' or 'TABLE' or FALSE. If FALSE, both views and tables are returned. "VIEW" returns only views "TABLE" returns only tables
showSchema   $showSchema   returns the schema/user with the table name, eg. USER.TABLE
mask   $mask   is the input mask - only supported by oci8 and postgresql

[ Top ]

method OffsetDate [line 530]

New OffsetDate( pDays $pDays, [pColumn $pColumn = NULL])

Calculate the offset of a date for a particular database and generate appropriate SQL. Useful for calculating future/past dates and storing in a database.



Tags:

return:  number of days
todo:  Not currently used - this is database specific and uses TIMESTAMP rather than unix seconds


Overrides BitDb::OffsetDate() (Calculate the offset of a date for a particular database and generate appropriate SQL. Useful for calculating future/past dates and storing in a database.)

Parameters:

pDays   $pDays   Number of days to offset by If dayFraction=1.5 means 1.5 days from now, 1.0/24 for 1 hour.
pColumn   $pColumn   Value to be offset If NULL an offset from the current time is supplied

[ Top ]

method qstr [line 169]

quoted qstr( pStr $pStr)

Quotes a string to be sent to the database which is passed to function on to AdoDB->qstr().



Tags:

return:  string using AdoDB->qstr()
todo:  not sure what its supposed to do


Overrides BitDb::qstr() (Quotes a string to be sent to the database)

Parameters:

pStr   $pStr   string to be quotes

[ Top ]

method query [line 231]

an query( pQuery $query, [pValues $values = FALSE], [pNumRows $numrows = BIT_QUERY_DEFAULT], [pOffset $offset = BIT_QUERY_DEFAULT], [ $pCacheTime = BIT_QUERY_DEFAULT])

Queries the database reporting an error if detected

than exiting while printing the error. -rlpowell




Tags:

return:  AdoDB RecordSet object


Overrides BitDb::query() (Queries the database reporting an error if detected)

Parameters:

pQuery   $query   the SQL query. Use backticks (`) to quote all table and attribute names for AdoDB to quote appropriately.
pValues   $values   an array of values used in a parameterised query
pNumRows   $numrows   the number of rows (LIMIT) to return in this query
pOffset   $offset   the row number to begin returning rows from. Used in conjunction with $pNumRows
   $pCacheTime  

[ Top ]

method queryError [line 203]

an queryError( pQuery $pQuery, pError &$pError, [pValues $pValues = NULL], [pNumRows $pNumRows = -1], [pOffset $pOffset = -1])

Queries the database, returning an error if one occurs, rather

than exiting while printing the error. -rlpowell




Tags:

return:  AdoDB RecordSet object conjunction with $pNumRows
todo:  currently not used anywhere.


Overrides BitDb::queryError() (Queries the database, returning an error if one occurs, rather)

Parameters:

pQuery   $pQuery   the SQL query. Use backticks (`) to quote all table and attribute names for AdoDB to quote appropriately.
pError   &$pError   the error string to modify and return
pValues   $pValues   an array of values used in a parameterised query
pNumRows   $pNumRows   the number of rows (LIMIT) to return in this query
pOffset   $pOffset   the row number to begin returning rows from. Used in

[ Top ]

method random [line 186]

string random( )

Returns RANDOM function appropiate for database.

Overrides BitDbBase::random()




Tags:

return:  using AdoDB->random property


Overrides BitDb::random() (A database portable RANDOM() function.)

[ Top ]

method RollbackTrans [line 608]

TRUE/FALSE. RollbackTrans( )

If database does not support transactions, rollbacks always fail, so return FALSE otherwise returns TRUE if the Rollback was successful



Overrides BitDb::RollbackTrans() (If database does not support transactions, rollbacks always fail, so return false otherwise returns true if the Rollback was successful)

[ Top ]

method SQLDate [line 513]

void SQLDate( $pDateFormat, [ $pBaseDate = FALSE])

Format date column in sql string given an input format that understands Y M D



Overrides BitDb::SQLDate() (Format date column in sql string given an input format that understands Y M D)

Parameters:

   $pDateFormat  
   $pBaseDate  

[ Top ]

method StartTrans [line 586]

void StartTrans( )

Improved method of initiating a transaction. Used together with CompleteTrans().

Advantages include:

a. StartTrans/CompleteTrans is nestable, unlike BeginTrans/CommitTrans/RollbackTrans. Only the outermost block is treated as a transaction.
b. CompleteTrans auto-detects SQL errors, and will rollback on errors, commit otherwise.
c. All BeginTrans/CommitTrans/RollbackTrans inside a StartTrans/CompleteTrans block are disabled, making it backward compatible.




Overrides BitDb::StartTrans() (Improved method of initiating a transaction. Used together with CompleteTrans().)

[ Top ]

method substr [line 177]

string substr( )

Returns SUBSTRING function appropiate for database.



Tags:

return:  using AdoDB->substr property


[ Top ]

method tableExists [line 129]

TRUE tableExists( pTable $pTable)

Used to check if tables already exists.



Tags:

return:  if table already exists
todo:  should be used to confirm tables are already created


Overrides BitDb::tableExists() (Used to check if tables already exists.)

Parameters:

pTable   $pTable   the table name

[ Top ]


Documentation generated on Wed, 29 Jul 2015 13:55:48 +0000 by phpDocumentor 1.5.0-lsces