XOOPS  2.6.0
Xoops\Core\Database\Connection Class Reference
Inheritance diagram for Xoops\Core\Database\Connection:
Inheritance graph

Public Member Functions

 __construct (array $params,\Doctrine\DBAL\Driver $driver,\Doctrine\DBAL\Configuration $config=null,\Doctrine\Common\EventManager $eventManager=null)
 
 beginTransaction ()
 
 commit ()
 
 createXoopsQueryBuilder ()
 
 deletePrefix ($tableName, array $identifier)
 
 executeQuery ($query, array $params=array(), $types=array(),\Doctrine\DBAL\Cache\QueryCacheProfile $qcp=null)
 
 executeUpdate ($query, array $params=array(), array $types=array())
 
 insertPrefix ($tableName, array $data, array $types=array())
 
 query ()
 
 queryFromFile ($file)
 
 quoteSlash ($input)
 
 rollBack ()
 
 updatePrefix ($tableName, array $data, array $identifier, array $types=array())
 

Static Public Member Functions

static getForce ()
 
static getSafe ()
 
static prefix ($tablename= '')
 
static setForce ($force=false)
 
static setSafe ($safe=true)
 

Static Protected Attributes

static $force
 
static $safe
 
static $transactionActive
 

Detailed Description

Definition at line 29 of file Connection.php.

Constructor & Destructor Documentation

Xoops\Core\Database\Connection::__construct ( array  $params,
\Doctrine\DBAL\Driver  $driver,
\Doctrine\DBAL\Configuration  $config = null,
\Doctrine\Common\EventManager  $eventManager = null 
)

Initializes a new instance of the Connection class.

This sets up necessary variables before calling parent constructor

Parameters
array$paramsParameters for the driver
Driver$driverThe driver to use
Configuration$configThe connection configuration
EventManager$eventManagerEvent manager to use

Definition at line 107 of file Connection.php.

References $_SERVER, and Xoops\$config.

Member Function Documentation

Xoops\Core\Database\Connection::beginTransaction ( )

Starts a transaction by suspending auto-commit mode.

Returns
void

Definition at line 284 of file Connection.php.

Xoops\Core\Database\Connection::commit ( )

Commits the current transaction.

Returns
void

Definition at line 295 of file Connection.php.

Xoops\Core\Database\Connection::createXoopsQueryBuilder ( )

Create a new instance of a SQL query builder.

Returns

Definition at line 397 of file Connection.php.

Xoops\Core\Database\Connection::deletePrefix (   $tableName,
array  $identifier 
)

Executes an SQL DELETE statement on a table.

Adds prefix to the name of the table then passes to delete function.

Parameters
string$tableNameThe name of the table on which to delete.
array$identifierThe deletion criteria. An associative array containing column-value pairs.
Returns
integer The number of affected rows.

Definition at line 201 of file Connection.php.

References Xoops\Core\Database\Connection\prefix().

Here is the call graph for this function:

Xoops\Core\Database\Connection::executeQuery (   $query,
array  $params = array(),
  $types = array(),
\Doctrine\DBAL\Cache\QueryCacheProfile  $qcp = null 
)

Executes an, optionally parameterized, SQL query.

If the query is parameterized, a prepared statement is used. If an SQLLogger is configured, the execution is logged.

Parameters
string$queryThe SQL query to execute.
array$paramsThe parameters to bind to the query, if any.
array$typesThe types the previous parameters are in.
QueryCacheProfile$qcpThe query Cache profile
Returns
The executed statement.

PERF: Directly prepares a driver statement, not a wrapper.

Definition at line 222 of file Connection.php.

References $query.

Xoops\Core\Database\Connection::executeUpdate (   $query,
array  $params = array(),
array  $types = array() 
)

Executes an SQL INSERT/UPDATE/DELETE query with the given parameters and returns the number of affected rows.

This method supports PDO binding types as well as DBAL mapping types.

This over ridding process checks to make sure it is safe to do these. If force is active then it will over ride the safe setting.

Parameters
string$queryThe SQL query.
array$paramsThe query parameters.
array$typesThe parameter types.
Returns
integer The number of affected rows.

PERF: Directly prepares a driver statement, not a wrapper.

Todo:
build a better exception catching system.

Definition at line 250 of file Connection.php.

References $query, $result, and Xoops\getInstance().

Here is the call graph for this function:

static Xoops\Core\Database\Connection::getForce ( )
static

this is a public getter for the $force variable

Returns
boolean

Definition at line 92 of file Connection.php.

static Xoops\Core\Database\Connection::getSafe ( )
static

this is a public getter for the safe variable

Returns
boolean

Definition at line 68 of file Connection.php.

Xoops\Core\Database\Connection::insertPrefix (   $tableName,
array  $data,
array  $types = array() 
)

Inserts a table row with specified data.

Adds prefix to the name of the table then passes to normal function.

Parameters
string$tableNameThe name of the table to insert data into.
array$dataAn associative array containing column-value pairs.
array$typesTypes of the inserted data.
Returns
integer The number of affected rows.

Definition at line 162 of file Connection.php.

References Xoops\Core\Database\Connection\prefix().

Here is the call graph for this function:

static Xoops\Core\Database\Connection::prefix (   $tablename = '')
static
Xoops\Core\Database\Connection::query ( )

perform a safe query if allowed can receive variable number of arguments

Returns
returns the value received or null if nothing received.
Todo:

add error report for using non select while not safe.

need to check if doctrine allows more than one query to be sent. This code assumes only one query is sent and anything else sent is not a query. This will have to be readdressed if this is wrong.

Definition at line 326 of file Connection.php.

References $result, $sql, and Xoops\getInstance().

Referenced by Xoops\Core\Database\Connection\queryFromFile().

Here is the call graph for this function:

Here is the caller graph for this function:

Xoops\Core\Database\Connection::queryFromFile (   $file)

perform queries from SQL dump file in a batch

Parameters
string$filefile path to an SQL dump file
Returns
bool FALSE if failed reading SQL file or TRUE if the file has been read and queries executed

Definition at line 362 of file Connection.php.

References $file, $query, Xoops\Core\Database\Connection\prefix(), SqlUtility\prefixQuery(), Xoops\Core\Database\Connection\query(), and SqlUtility\splitMySqlFile().

Here is the call graph for this function:

Xoops\Core\Database\Connection::quoteSlash (   $input)

Duplicates original xoops quote. Name changed to not confuse normal usage of quote.

Parameters
string$inputtest to convert
Returns
mixed converted text

Definition at line 386 of file Connection.php.

Xoops\Core\Database\Connection::rollBack ( )

rolls back the current transaction.

Returns
void

Definition at line 307 of file Connection.php.

static Xoops\Core\Database\Connection::setForce (   $force = false)
static

this is a public setter for the $force variable

Parameters
bool$forcewhen true will force a write to database when safe is false.
Returns
void

Definition at line 80 of file Connection.php.

References Xoops\Core\Database\Connection\$force.

static Xoops\Core\Database\Connection::setSafe (   $safe = true)
static

this is a public setter for the safe variable

Parameters
bool$safeset safe to true if safe to write data to database
Returns
void

Definition at line 56 of file Connection.php.

References Xoops\Core\Database\Connection\$safe.

Xoops\Core\Database\Connection::updatePrefix (   $tableName,
array  $data,
array  $identifier,
array  $types = array() 
)

Executes an SQL UPDATE statement on a table.

Adds prefix to the name of the table then passes to normal function.

Parameters
string$tableNameThe name of the table to update.
array$dataThe data to update
array$identifierThe update criteria. An associative array containing column-value pairs.
array$typesTypes of the merged $data and $identifier arrays in that order.
Returns
integer The number of affected rows.

Definition at line 183 of file Connection.php.

References Xoops\Core\Database\Connection\prefix().

Here is the call graph for this function:

Member Data Documentation

Xoops\Core\Database\Connection::$force
staticprotected

Definition at line 41 of file Connection.php.

Referenced by Xoops\Core\Database\Connection\setForce().

Xoops\Core\Database\Connection::$safe
staticprotected

Definition at line 35 of file Connection.php.

Referenced by Xoops\Core\Database\Connection\setSafe().

Xoops\Core\Database\Connection::$transactionActive
staticprotected

Definition at line 46 of file Connection.php.


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