UNA
Loading...
Searching...
No Matches
BxDolDb Class Reference
Inheritance diagram for BxDolDb:
BxDolFactory iBxDolSingleton BxDolAIQuery 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 ()
 
 setReadOnlyMode ($b)
 
 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)
 
 lastId ()
 
 query ($oStatement, $aBindings=array(), $bVerbose=null)
 
 res ($oStatement, $aBindings=array(), $bVerbose=null)
 
 getServerInfo ()
 
 getVersion ()
 
 listTables ()
 
 getFields ($sTable)
 
 fetchField ($oStatement, $iField, $aBindings=array())
 
 isTableExists ($sTable)
 
 isFieldExists ($sTable, $sFieldName)
 
 isIndexExists ($sTable, $sIndexName)
 
 error ($aError)
 
 cacheParams ($bForceCacheInvalidate=false, $bForceCacheInvalidateMixed=false)
 
 cacheParamsClear ($sCacheName='')
 
 isParam ($sKey, $bFromCache=true)
 
 addParam ($sName, $sValue, $iKateg, $sDesc, $sType)
 
 getParam ($sKey, $bFromCache=true)
 
 setParam ($sKey, $mixedValue, $iMixId=0)
 
 getParamsMix ($iId)
 
 getParamsMixActive ($sType)
 
 getParamsMixes ($sType, $mixedPublished=false)
 
 setTimezone ($sTimezone)
 
 getEncoding ()
 
 setErrorChecking ($b)
 
 getDbCacheObject ()
 
 genDbCacheKey ($sName)
 
 getCache ($sName, $sFunc)
 
 setCache ($sName, $mData)
 
 fromCache ($sName, $sFunc)
 
 cleanCache ($sName)
 
fromMemory ($sName, $sFunc)
 
 cleanMemory ($sName)
 
 cleanMemoryAll ()
 
 escape ($s)
 
 implode_escape ($mixed)
 
 unescape ($mixed)
 
 prepare ($sQuery)
 
 prepareAsString ($sQuery)
 
 arrayToSQL ($a, $sDiv=',', $sOperator='=', $bWildcardSpaceChars=false)
 
 executeSQL ($sPath, $aReplace=array(), $isBreakOnError=true)
 

Static Public Member Functions

static getInstance ()
 
static getInstanceWithConf ($aDbConf, &$sError)
 
static getLink ()
 

Protected Member Functions

 __construct ($aDbConf=false)
 
 balancer ()
 
 isParamInCache ($sKey)
 
 log ($s)
 
 executeStatement ($oStatement, $aBindings=array(), $bVerbose=null, &$iErrorCode=null)
 
 executeStatementException ($oStatement, $aBindings=array(), $bVerbose=null)
 
 executeStatementSilent ($oStatement, $aBindings=array(), $bVerbose=null)
 
 errorOutput ($aError)
 

Protected Attributes

 $_bPdoPersistent
 
 $_iPdoFetchType
 
 $_iPdoErrorMode
 
 $_bErrorChecking
 
 $_aError
 
 $_sHost
 
 $_sPort
 
 $_sSocket
 
 $_sDbname
 
 $_sUser
 
 $_sPassword
 
 $_sCharset
 
 $_sStorageEngine
 
 $_oStatement = null
 
 $_oDbCacheObject = null
 

Static Protected Attributes

static $_rLink
 
static $_aDbCacheData
 
static $_aParams
 
static $_sParamsCacheName = 'sys_options'
 
static $_sParamsCacheNameMixed = 'sys_options_mixed_'
 
static $_sParamsCacheNameMix = 'sys_options_mix_'
 
static $_sErrorKey = 'bx_db_error'
 
static $_aErrors
 
static $_bReadOnlyMode = true
 
static $_bMultuServersMode = false
 

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ __clone()

◆ 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.

◆ 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()

◆ 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

Reimplemented in BxAdsDb, and BxPaymentDb.

◆ 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)

Member Data Documentation

◆ $_aErrors

BxDolDb::$_aErrors
staticprotected
Initial value:
= array(
BX_DB_ERR_CONNECT_FAILD => 'Database connect failed',
BX_DB_ERR_QUERY_ERROR => 'Database query error',
BX_DB_ERR_ESCAPE => 'Escape string error'
)

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