UNA
BxDolDb Class Reference
Inheritance diagram for BxDolDb:
BxDolFactory iBxDolSingleton BxDolAccountQuery BxDolAclQuery BxDolApiQuery BxDolAuditQuery BxDolBadgesQuery BxDolCategoriesQuery BxDolCategoryQuery BxDolChartQuery BxDolCmtsQuery BxDolConnectionQuery BxDolCronQuery BxDolEditorQuery BxDolEmailTemplatesQuery BxDolFactoryObjectQuery BxDolFileHandlerQuery BxDolFormQuery BxDolGridQuery BxDolKeyQuery BxDolLabelQuery BxDolLanguagesQuery BxDolLiveUpdatesQuery BxDolLogsQuery BxDolMenuQuery BxDolMetatagsQuery BxDolModuleQuery BxDolObjectQuery BxDolPageQuery BxDolPaymentsQuery BxDolPermalinks BxDolPlayerQuery BxDolPreloaderQuery BxDolPrivacyQuery BxDolProfileQuery BxDolQueueQuery BxDolRecommendationQuery BxDolRewriteRulesQuery BxDolRssQuery BxDolSearchExtendedQuery BxDolSessionQuery BxDolStorageQuery BxDolStudioFormsQuery BxDolStudioNavigationQuery BxDolStudioOptionsQuery BxDolStudioPageQuery BxDolStudioRolesQuery BxDolStudioStoragesQuery BxDolTranscoderQuery BxDolUploaderQuery BxDolWikiQuery

Public Member Functions

 __clone ()
 
 connect ()
 
 disconnect ()
 
 ping ()
 
 pdoExec ($sQuery)
 
 pdoQuery ($sQuery)
 
 pdoExceptionHandler ($oException)
 
 getOption ($sName)
 
 getOne ($oStatement, $aBindings=array(), $iIndex=0)
 
 getRow ($oStatement, $aBindings=array(), $iFetchType=PDO::FETCH_ASSOC)
 
 getColumn ($oStatement, $aBindings=array(), $iFetchColumnNumber=0)
 
 getFirstRow ($oStatement, $aBindings=array(), $iFetchType=PDO::FETCH_ASSOC)
 
 getNextRow ($iFetchType=PDO::FETCH_ASSOC)
 
 getAll ($oStatement, $aBindings=array(), $iFetchType=PDO::FETCH_ASSOC)
 
 fillArray ($oStatement, $aBindings=array(), $iFetchType=PDO::FETCH_ASSOC)
 
 getAllWithKey ($oStatement, $sFieldKey, $aBindings=array(), $iFetchType=PDO::FETCH_ASSOC)
 
 getPairs ($oStatement, $sFieldKey, $sFieldValue, $aBindings=array(), $iFetchType=PDO::FETCH_ASSOC)
 
 getNumRows ($oStatement=null)
 
 getAffectedRows ($oStatement=null)
 
 query ($oStatement, $aBindings=array(), $bVerbose=null)
 
 res ($oStatement, $aBindings=array(), $bVerbose=null)
 
 getServerInfo ()
 
 getVersion ()
 
 listTables ()
 
 getDbCacheObject ()
 
 escape ($s)
 
 implode_escape ($mixed)
 
 unescape ($mixed)
 
 prepare ($sQuery)
 
 prepareAsString ($sQuery)
 
 arrayToSQL ($a, $sDiv=',', $sOperator='=', $bWildcardSpaceChars=false)
 

Static Public Member Functions

static getInstance ()
 

Protected Member Functions

 __construct ($aDbConf=false)
 

Constructor & Destructor Documentation

◆ __construct()

BxDolDb::__construct (   $aDbConf = false)
protected

set database parameters and connect to it

Member Function Documentation

◆ __clone()

BxDolDb::__clone ( )

Prevent cloning the instance

◆ arrayToSQL()

BxDolDb::arrayToSQL (   $a,
  $sDiv = ',',
  $sOperator = '=',
  $bWildcardSpaceChars = false 
)

Convert array of key => values to SQL query. Array keys are field names and array values are field values.

Parameters
$aarray
$sDivfields separator, by default it is ',', another useful value is ' AND '
$sOperatoroperator for comparision: '=' or 'LIKE'
$bWildcardSpaceCharssubstiture any space and dash characters with single wildcard symbol
Returns
part of SQL query string

◆ connect()

BxDolDb::connect ( )

connect to database with appointed parameters

◆ disconnect()

BxDolDb::disconnect ( )

close mysql connection

◆ escape()

BxDolDb::escape (   $s)

It escapes string to pass to mysql query. Try to use "prepare" function always (

See also
BxDolDb::prepare), use "escape" only if "prepare" function is not possible at all. Also consider using "implode_escape" function (
BxDolDb::implode_escape).
Parameters
string$sstring to escape
Returns
escaped string whcich is ready to pass to SQL query.

◆ fillArray()

BxDolDb::fillArray (   $oStatement,
  $aBindings = array(),
  $iFetchType = PDO::FETCH_ASSOC 
)

Executes sql query and returns table of records as result.

Deprecated:
use getAll instead.

◆ getAffectedRows()

BxDolDb::getAffectedRows (   $oStatement = null)

returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement.

◆ getAll()

BxDolDb::getAll (   $oStatement,
  $aBindings = array(),
  $iFetchType = PDO::FETCH_ASSOC 
)

execute sql query and return table of records as result

◆ getAllWithKey()

BxDolDb::getAllWithKey (   $oStatement,
  $sFieldKey,
  $aBindings = array(),
  $iFetchType = PDO::FETCH_ASSOC 
)

execute sql query and return table of records as result

◆ getColumn()

BxDolDb::getColumn (   $oStatement,
  $aBindings = array(),
  $iFetchColumnNumber = 0 
)

execute sql query and return a column as result

◆ getDbCacheObject()

BxDolDb::getDbCacheObject ( )

Cache functions.

◆ getFirstRow()

BxDolDb::getFirstRow (   $oStatement,
  $aBindings = array(),
  $iFetchType = PDO::FETCH_ASSOC 
)

execute sql query and return the first row of result and keep $array type and poiter to all data

◆ getInstance()

static BxDolDb::getInstance ( )
static

Get singleton instance of the class

Implements iBxDolSingleton.

◆ getNextRow()

BxDolDb::getNextRow (   $iFetchType = PDO::FETCH_ASSOC)

return next row of pointed last getFirstRow calling data

◆ getNumRows()

BxDolDb::getNumRows (   $oStatement = null)

return number of affected rows in current mysql result

NOTE: PDOStatement::rowCount works for SELECT queries in MySQL. So, this method should be rewritten if the other DB engine will be used.

◆ getOne()

BxDolDb::getOne (   $oStatement,
  $aBindings = array(),
  $iIndex = 0 
)

execute sql query and return one value result

◆ getOption()

BxDolDb::getOption (   $sName)

get mysql option

◆ getPairs()

BxDolDb::getPairs (   $oStatement,
  $sFieldKey,
  $sFieldValue,
  $aBindings = array(),
  $iFetchType = PDO::FETCH_ASSOC 
)

execute sql query and return table of records as result

◆ getRow()

BxDolDb::getRow (   $oStatement,
  $aBindings = array(),
  $iFetchType = PDO::FETCH_ASSOC 
)

execute sql query and return one row result

◆ getServerInfo()

BxDolDb::getServerInfo ( )

get mysql server info

◆ getVersion()

BxDolDb::getVersion ( )

get mysql version

◆ implode_escape()

BxDolDb::implode_escape (   $mixed)

This function is usefull when you need to form array of parameters to pass to IN(...) SQL construction. Example:

$a = array(2, 4.5, 'apple', 'car');
$s = "SELECT * FROM `t` WHERE `a` IN (" . $oDb->implode_escape($a) . ")";
echo $s; // outputs: SELECT * FROM `t` WHERE `a` IN (2, 4.5, 'apple', 'car')
Parameters
$mixedarray or parameters or just one paramter
Returns
string which is ready to pass to IN(...) SQL construction

◆ listTables()

BxDolDb::listTables ( )

get list of tables in database

◆ pdoExceptionHandler()

BxDolDb::pdoExceptionHandler (   $oException)

database query exception handler for exceptions appeared out of the try/catch block

◆ pdoExec()

BxDolDb::pdoExec (   $sQuery)

Can be used to execute queries which shouldn't return data

◆ pdoQuery()

BxDolDb::pdoQuery (   $sQuery)

Executes query and returns PDOStatement object or false

◆ ping()

BxDolDb::ping ( )

check mysql connection

◆ prepare()

BxDolDb::prepare (   $sQuery)

Prepare SQL query before execution if some arguments are need to be passed to it. All parameters marked with question (?) symbol in SQL query are replaced with parameters passed after SQL query parameter. Parameters are properly excaped and surrounded by qutes if needed. Example:

$sSql = $oDb->prepare("SELECT `a`, `b` from `t` WHERE `c` = ? and `d` = ?", 12, 'aa');
echo $sSql;// outputs: SELECT `a`, `b` from `t` WHERE `c` = 12 and `d` = 'aa'
$a = $oDb->getAll($sSql);
Parameters
string$sQuerySQL query, parameters for replacing are marked with ? symbol
mixed$mixedany number if parameters to replace, number of parameters whould match number of ? symbols in SQL query
Returns
PDOStatement object with SQL query ready for execution

◆ prepareAsString()

BxDolDb::prepareAsString (   $sQuery)

Prepare SQL query before execution if some arguments are need to be passed to it. All parameters marked with question (?) symbol in SQL query are replaced with parameters passed after SQL query parameter. Parameters are properly excaped and surrounded by qutes if needed. Example:

$sSql = $oDb->prepare("SELECT `a`, `b` from `t` WHERE `c` = ? and `d` = ?", 12, 'aa');
echo $sSql;// outputs: SELECT `a`, `b` from `t` WHERE `c` = 12 and `d` = 'aa'
$a = $oDb->getAll($sSql);
Parameters
string$sQuerySQL query, parameters for replacing are marked with ? symbol
mixed$mixedany number if parameters to replace, number of parameters whould match number of ? symbols in SQL query
Returns
string with SQL query.

◆ query()

BxDolDb::query (   $oStatement,
  $aBindings = array(),
  $bVerbose = null 
)

execute any query return number of rows affected/false

◆ res()

BxDolDb::res (   $oStatement,
  $aBindings = array(),
  $bVerbose = null 
)

execute any query

◆ unescape()

BxDolDb::unescape (   $mixed)

The documentation for this class was generated from the following file: