OXID eShop CE  4.10.6
 All Classes Namespaces Files Functions Variables Pages
oxLegacyDb Class Reference
+ Inheritance diagram for oxLegacyDb:
+ Collaboration diagram for oxLegacyDb:

Public Member Functions

 setConnection ($oConnection)
 forceMasterConnection ()
 setFetchMode ($iFetchMode)
 getDb ($blType=true)
 getOne ($sSql, $aParams=array(), $blType=true)
 getArray ($sSql, $aParams=array(), $blType=true)
 getRow ($sSql, $aParams=array(), $blType=true)
 getAll ($sSql, $aParams=array(), $blType=true)
 select ($sSql, $aParams=array(), $blType=true)
 getAssoc ($sSql, $aParams=array(), $blType=true)
 getCol ($sSql, $aParams=array(), $blType=true)
 selectLimit ($sSql, $iRows=-1, $iOffset=-1, $aParams=array(), $blType=true)
 execute ($sSql, $aParams=array())
 query ($sSql, $aParams=array())
 Affected_Rows ()
 errorNo ()
 errorMsg ()
 qstr ($sValue)
 quote ($sValue)
 quoteArray ($aStrArray)
 metaColumns ($sTable)
 metaColumnNames ($sTable, $blNumIndexes=false)
 startTransaction ()
 commitTransaction ()
 rollbackTransaction ()
 setTransactionIsolationLevel ($sLevel=null)
 UI ($iPollSecs=5)
 Insert_ID ()
 lastInsertId ()
 getLastInsertId ()
- Public Member Functions inherited from oxSuperCfg
 __call ($sMethod, $aArgs)
 __construct ()
 getConfig ()
 setConfig ($oConfig)
 getSession ()
 setSession ($oSession)
 getUser ()
 setUser ($oUser)
 isAdmin ()
 setAdminMode ($blAdmin)

Protected Attributes

 $_oDb = null

Additional Inherited Members

- Public Attributes inherited from DatabaseInterface
const FETCH_MODE_DEFAULT = 0
const FETCH_MODE_NUM = 1
const FETCH_MODE_ASSOC = 2
const FETCH_MODE_BOTH = 3
- Static Protected Attributes inherited from oxSuperCfg
static $_oConfig = null
static $_oSession = null
static $_oRights = null
static $_oActUser = null
static $_blIsAdmin = null

Detailed Description

Database connection class

Deprecated:
since v5.3.0 (2016-04-19); This class will be removed. There will be a DatabaseInterface in v6.0 which includes all but the deprecated methods of oxLegacyDb. An implementation of the DatabaseInterface based on Doctrine DBAL will replace oxLegacyDb.

Definition at line 15 of file oxlegacydb.php.

Member Function Documentation

oxLegacyDb::Affected_Rows ( )

Returns the count of rows affected by the last query. This is an alias for affectedRows().

Deprecated:
since v5.3.0 (2016-04-14); This method will be removed in v6.0. Use the return value of execute() instead.
Returns
int

Definition at line 183 of file oxlegacydb.php.

oxLegacyDb::commitTransaction ( )

Commit a database transaction.

Exceptions
Exception

Implements DatabaseInterface.

Definition at line 282 of file oxlegacydb.php.

oxLegacyDb::errorMsg ( )

Return error message

Deprecated:
since v5.3.0 (2016-04-14); This information will be part of the thrown DatabaseException exception. Replace usage by catching DatabaseException and using DatabaseException->getMessage()
Returns
string

Definition at line 209 of file oxlegacydb.php.

oxLegacyDb::errorNo ( )

Return error number

Deprecated:
since v5.3.0 (2016-04-14); This information will be part of the thrown DatabaseException exception. Replace usage by catching DatabaseException and using DatabaseException->getCode()
Returns
int

Definition at line 196 of file oxlegacydb.php.

oxLegacyDb::execute (   $sSql,
  $aParams = array() 
)

Execute non read statements like INSERT, UPDATE, DELETE and return the number of rows affected by the statement.Execute read statements like SELECT or SHOW and return the results as a ResultSet. (This behavior is deprecated since v5.3.0 (2016-06-06) This method has to be used EXCLUSIVELY for non read statements in v6.0)IMPORTANT: You are strongly encouraged to use prepared statements like this: $resultSet = DatabaseInterfaceImplementation::getDb->execute( 'DELETE * FROM mytable WHERE id = ? OR id = ?', array($id1, $id2) ); If you will not use prepared statements, you MUST quote variables the values with quote(), otherwise you create a SQL injection vulnerability.

Parameters
string$queryThe sql statement we want to execute.
array$parametersThe parameters array.
Returns
object
Deprecated:
since v5.3.0 (2016-06-06) This method will return an integer as the number of rows affected by the statement for non read statements. An exception will be thrown, if a read statement is passed to this function.

Implements DatabaseInterface.

Definition at line 155 of file oxlegacydb.php.

oxLegacyDb::forceMasterConnection ( )

Force database master connection.Hint: this method is here to have an easier update path. It will be implemented in the OXID eShop version 6.0.

Implements DatabaseInterface.

Definition at line 41 of file oxlegacydb.php.

oxLegacyDb::getAll (   $sSql,
  $aParams = array(),
  $blType = true 
)

Get an multi-dimensional array of arrays with the values of the all rows of a given sql SELECT or SHOW statement. Returns an empty array for any other statement.The keys of the first level array are numeric. The keys of the second level arrays may be numeric, strings or both, depending on the FETCH_MODE_* of the connection. Set the desired fetch mode with DatabaseInterface::setFetchMode() before calling this method.IMPORTANT: You are strongly encouraged to use prepared statements like this: $result = DatabaseInterfaceImplementation::getDb->getAll( 'SELECT * FROM mytable WHERE id = ? OR id = ? LIMIT 0, 1', array($id1, $id2) ); If you will not use prepared statements, you MUST quote variables the values with quote(), otherwise you create a SQL injection vulnerability.

Parameters
string$queryIf parameters are given, the "?" in the string will be replaced by the values in the array
array$parametersArray of parameters, for the given sql statement.
bool$executeOnSlaveExecute this statement on the slave database. Only evaluated in a master-slave setup. This parameter is deprecated since v5.3.0 (2016-06-17). Different solution in 6.0.
See Also
DatabaseInterface::setFetchMode()
Doctrine::$fetchMode
Returns
array

Implements DatabaseInterface.

Definition at line 105 of file oxlegacydb.php.

oxLegacyDb::getArray (   $sSql,
  $aParams = array(),
  $blType = true 
)

Get value

Parameters
string$sSqlQuery
array$aParamsArray of parameters
bool$blTypeconnection type
Deprecated:
since v5.3.0 (2016-04-14); Use the method oxLegacyDb::getAll() instead.
Returns
array

Definition at line 89 of file oxlegacydb.php.

oxLegacyDb::getAssoc (   $sSql,
  $aParams = array(),
  $blType = true 
)

Get value

Parameters
string$sSqlQuery
array$aParamsArray of parameters
bool$blTypeconnection type
Deprecated:
since v5.3.0 (2016-04-14); This method will be removed. Rebuild the functionality of this method with your code using getAll with assoc fetch mode. In some use cases you should be able to simply use getRow
Returns
array

Definition at line 131 of file oxlegacydb.php.

oxLegacyDb::getCol (   $sSql,
  $aParams = array(),
  $blType = true 
)

Return the first column of all rows of the results of a given sql SELECT or SHOW statement as an numeric array. Throws an exception for any other statement.IMPORTANT: You are strongly encouraged to use prepared statements like this: $result = DatabaseInterfaceImplementation::getDb->getRow( 'SELECT * FROM mytable WHERE id = ? LIMIT 0, 1', array($id1) ); If you will not use prepared statements, you MUST quote variables the values with quote(), otherwise you create a SQL injection vulnerability.

Parameters
string$sqlSelectThe sql select statement
array$parametersThe parameters array.
bool$executeOnSlaveExecute this statement on the slave database. Only evaluated in a master-slave setup. This parameter is deprecated since v5.3.0 (2016-06-17). Different solution in 6.0.
Returns
array The values of the first column of a corresponding sql query.

Implements DatabaseInterface.

Definition at line 139 of file oxlegacydb.php.

oxLegacyDb::getDb (   $blType = true)

Return connection to db

Parameters
bool$blType- connection type
Deprecated:
since v5.3.0 (2016-04-14); This method will be protected in v6.0. Do not use any more.
Returns
object

Definition at line 64 of file oxlegacydb.php.

oxLegacyDb::getLastInsertId ( )

Returns last insert ID

Returns
int

Definition at line 353 of file oxlegacydb.php.

oxLegacyDb::getOne (   $sSql,
  $aParams = array(),
  $blType = true 
)

Get the first value of the first row of the result set of a given sql SELECT or SHOW statement. Returns false for any other statement.NOTE: Although you might pass any SELECT or SHOW statement to this method, try to limit the result of the statement to one single row, as the rest of the rows is simply discarded.

Parameters
string$queryThe sql SELECT or SHOW statement.
array$parametersArray of parameters for the given sql statement.
bool$executeOnSlaveExecute this statement on the slave database. Only evaluated in a master-slave setup. This parameter is deprecated since v5.3.0 (2016-06-17). Different solution in 6.0.
Returns
string|false Returns a string for SELECT or SHOW statements and FALSE for any other statement.

Implements DatabaseInterface.

Definition at line 73 of file oxlegacydb.php.

oxLegacyDb::getRow (   $sSql,
  $aParams = array(),
  $blType = true 
)

Get an array with the values of the first row of a given sql SELECT or SHOW statement . Returns an empty array for any other statement.The keys of the array may be numeric, strings or both, depending on the FETCH_MODE_* of the connection. Set the desired fetch mode with DatabaseInterface::setFetchMode() before calling this method.NOTE: Although you might pass any SELECT or SHOW statement to this method, try to limit the result of the statement to one single row, as the rest of the rows is simply discarded.IMPORTANT: You are strongly encouraged to use prepared statements like this: $result = DatabaseInterfaceImplementation::getDb->getOne( 'SELECT id FROM mytable WHERE id = ? LIMIT 0, 1', array($id1) ); If you will not use prepared statements, you MUST quote variables the values with quote(), otherwise you create a SQL injection vulnerability.

Parameters
string$sqlSelectThe sql select statement we want to execute.
array$parametersArray of parameters, for the given sql statement.
bool$executeOnSlaveExecute this statement on the slave database. Only evaluated in a master-slave setup. This parameter is deprecated since v5.3.0 (2016-06-17). Different solution in 6.0.
Returns
array

Implements DatabaseInterface.

Definition at line 97 of file oxlegacydb.php.

oxLegacyDb::Insert_ID ( )

Returns last insert ID. This method is an alias of getLastInsertId().

Deprecated:
since v5.3.0 (2016-04-14); This method will be removed in v6.0. Use lastInsertId instead.
Returns
int

Definition at line 330 of file oxlegacydb.php.

oxLegacyDb::lastInsertId ( )

Returns last insert ID This method is an alias of getLastInsertId().

Deprecated:
since v5.3.2 (2016-10-12); This method will be removed in v6.0. Use getLastInsertId instead.
Returns
int

Definition at line 343 of file oxlegacydb.php.

oxLegacyDb::metaColumnNames (   $sTable,
  $blNumIndexes = false 
)

return meta data

Parameters
string$sTableTable name
bool$blNumIndexesNumeric indexes
Deprecated:
since v5.3.0 (2016-04-13); Not used. In v6.0 this method will be removed.
Returns
array

Definition at line 266 of file oxlegacydb.php.

oxLegacyDb::metaColumns (   $sTable)

Return the meta data for the columns of a table.

Parameters
string$tableThe name of the table.
Returns
array The meta information about the columns.

Implements DatabaseInterface.

Definition at line 251 of file oxlegacydb.php.

oxLegacyDb::qstr (   $sValue)

Quote string

Parameters
string$sValuevalue
Deprecated:
since v5.3.0 (2016-04-14); Use the method oxLegacyDb::quote() instead.
Returns
string

Definition at line 223 of file oxlegacydb.php.

oxLegacyDb::query (   $sSql,
  $aParams = array() 
)

Execute query

Parameters
string$sSqlQuery
array$aParamsArray of parameters
Deprecated:
since v5.3.0 (2016-04-15); This method will be removed in v6.0. Please use the method execute() instead.
Returns
object

Definition at line 170 of file oxlegacydb.php.

oxLegacyDb::quote (   $sValue)

Quote a string or a numeric value in a way, that it might be used as a value in a sql statement. Returns false for values that cannot be quoted.NOTE: It is not safe to use the return value of this function in a query. There will be no risk of SQL injection, but when the statement is executed and the value could not have been quoted, a DatabaseException is thrown. You are strongly encouraged to always use prepared statements instead of quoting the values on your own. E.g. use $resultSet = DatabaseInterfaceImplementation::getDb->select( 'SELECT * FROM mytable WHERE id = ? OR id = ?', array($id1, $id2) ); instead of $resultSet = DatabaseInterfaceImplementation::getDb->select( 'SELECT * FROM mytable WHERE id = ' . DatabaseInterfaceImplementation::getDb->quote($id1) . ' OR id = ' . DatabaseInterfaceImplementation::getDb->quote($id1) );

Parameters
mixed$valueThe string or numeric value to be quoted.
Returns
false|string The given string or numeric value converted to a string surrounded by single quotes or set to false, if the value could not have been quoted.

Implements DatabaseInterface.

Definition at line 231 of file oxlegacydb.php.

oxLegacyDb::quoteArray (   $aStrArray)

Quote every value in a given array in a way, that it might be used as a value in a sql statement and return the result as a new array. Numeric values will be converted to strings which quotes. The keys and their order of the returned array will be the same as of the input array.NOTE: It is not safe to use the return value of this function in a query. There will be no risk of SQL injection, but when the statement is executed and the value could not have been quoted, a DatabaseException is thrown. You are strongly encouraged to always use prepared statements instead of quoting the values on your own.

Parameters
array$arrayThe strings to quote as an array.
Returns
array Array with all string and numeric values quoted with single quotes or set to false, if the value could not have been quoted.

Implements DatabaseInterface.

Definition at line 239 of file oxlegacydb.php.

oxLegacyDb::rollbackTransaction ( )

RollBack a database transaction.

Exceptions
Exception

Implements DatabaseInterface.

Definition at line 290 of file oxlegacydb.php.

oxLegacyDb::select (   $sSql,
  $aParams = array(),
  $blType = true 
)

Return the results of a given sql SELECT or SHOW statement as a ResultSet. Throws an exception for any other statement.The values of first row of the result may be via resultSet's fields property. This property is an array, which keys may be numeric, strings or both, depending on the FETCH_MODE_* of the connection. All further rows can be accessed via the specific methods of ResultSet.IMPORTANT: You are strongly encouraged to use prepared statements like this: $resultSet = DatabaseInterfaceImplementation::getDb->select( 'SELECT * FROM mytable WHERE id = ? OR id = ?', array($id1, $id2) ); If you will not use prepared statements, you MUST quote variables the values with quote(), otherwise you create a SQL injection vulnerability.

Parameters
string$sqlSelectThe sql select statement
array$parametersThe parameters array.
bool$executeOnSlaveExecute this statement on the slave database. Only evaluated in a master-slave setup. This parameter is deprecated since v5.3.0 (2016-06-17). Different solution in 6.0.
Exceptions
ExceptionThe exception, that can occur while executing the sql statement.
Returns
object The result of the given query.
Deprecated:
since v5.3.0 (2016-06-16) This method will return an instance of ResultSetInterface in v6.0.

Implements DatabaseInterface.

Definition at line 114 of file oxlegacydb.php.

oxLegacyDb::selectLimit (   $sSql,
  $iRows = -1,
  $iOffset = -1,
  $aParams = array(),
  $blType = true 
)

Return the results of a given sql SELECT or SHOW statement limited by a LIMIT clause as a ResultSet. Throws an exception for any other statement.The values of first row of the result may be via resultSet's fields property. This property is an array, which keys may be numeric, strings or both, depending on the FETCH_MODE_* of the connection. All further rows can be accessed via the specific methods of ResultSet.IMPORTANT: You are strongly encouraged to use prepared statements like this: $resultSet = DatabaseInterfaceImplementation::getDb->selectLimit( 'SELECT * FROM mytable WHERE id = ? OR id = ?', $rowCount, $offset, array($id1, $id2) ); If you will not use prepared statements, you MUST quote variables the values with quote(), otherwise you create a SQL injection vulnerability.

Parameters
string$sqlSelectThe sql select statement
int$rowCountMaximum number of rows to return
int$offsetOffset of the first row to return. The current default value of -1 is
Deprecated:
since v5.3.3 (2017-03-28). The default value in V6.0 is zero.
Parameters
array$parametersThe parameters array.
bool$executeOnSlaveExecute this statement on the slave database. Only evaluated in a master-slave setup. This parameter is deprecated since v5.3.0 (2016-06-17). Different solution in 6.0.
Exceptions
ExceptionThe exception, that can occur while executing the sql statement.
Returns
object The result of the given query.
Deprecated:
since v5.3.0 (2016-06-16) This method will return an instance of ResultSetInterface in v6.0.

Implements DatabaseInterface.

Definition at line 147 of file oxlegacydb.php.

oxLegacyDb::setConnection (   $oConnection)

Set connection

Parameters
object$oConnectionConnection
Deprecated:
since v5.3.0 (2016-04-21); This method will be protected in v6.0. Do not use any more.

Definition at line 33 of file oxlegacydb.php.

oxLegacyDb::setFetchMode (   $iFetchMode)

Set the fetch mode of an open database connection.After the connection has been opened, this method may be used to set the fetch mode to any of the valid fetch modes as defined in DatabaseInterface::FETCH_MODE_*NOTE: This implies, that it is not safe to make any assumptions about the current fetch mode of the connection.

Parameters
int$fetchModeSee DatabaseInterface::FETCH_MODE_* for valid values

Implements DatabaseInterface.

Definition at line 49 of file oxlegacydb.php.

oxLegacyDb::setTransactionIsolationLevel (   $sLevel = null)

Set the transaction isolation level. Allowed values 'READ UNCOMMITTED', 'READ COMMITTED', 'REPEATABLE READ' and 'SERIALIZABLE'.NOTE: Currently the transaction isolation level is set on the database session and not globally. Setting the transaction isolation level globally requires root privileges in MySQL an this application should not be executed with root privileges. If you need to set the transaction isolation level globally, ask your database administrator to do so,

Parameters
string$levelThe transaction isolation level
Exceptions
Exception

Implements DatabaseInterface.

Definition at line 298 of file oxlegacydb.php.

oxLegacyDb::startTransaction ( )

Start a database transaction.

Exceptions
Exception

Implements DatabaseInterface.

Definition at line 274 of file oxlegacydb.php.

oxLegacyDb::UI (   $iPollSecs = 5)

Calls Db UI method

Parameters
integer$iPollSecspoll seconds
Deprecated:
since v5.3.0 (2016-06-07); This method will be removed in v6.0.

Definition at line 317 of file oxlegacydb.php.

Member Data Documentation

oxLegacyDb::$_oDb = null
protected

Definition at line 23 of file oxlegacydb.php.


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