Abstract Class BaseConnector

Description

Implements interfaces:

The BaseConnector implements common tasks for all IConnector classes in this package.

You can't create an instance of this class (it's abstract). Extend it to create new IConnector classes, e.g. for PHP database extensions not contained in this package.

Located in /BaseConnector.php (line 57)


	
			
Direct descendents
Class Description
 class MssqlConnector IConnector implementation for the PHP MSSQL database extension.
 class MysqlConnector IConnector implementation for the PHP MySQL database extension.
 class OdbcConnector IConnector implementation for the PHP ODBC database extension.
 class PdoConnector IConnector implementation for the PHP Data Objects.
 class SqlsrvConnector IConnector implementation for Microsoft SQL Server 2005 Driver for PHP.
Variable Summary
 array $cache
 resource $conn
 array $options
Method Summary
 BaseConnector BaseConnector ([array $options = array()])
 string bind (string $query, array $param, [array &$stack = array()], [array $options = array()])
 string cast (mixed $value, string $name, array &$stack, [array $options = array()])
 string castArray (array $list, string $name, array &$stack, [array $options = array()])
 string castBool (bool $value, string $name, array &$stack, [array $options = array()])
 string castDate (DateTime $value, string $name, array &$stack, [array $options = array()])
 string castFloat (float $value, string $name, array &$stack, [array $options = array()])
 string castInt (int $value, string $name, array &$stack, [array $options = array()])
 string castNull (null $value, string $name, array &$stack, [array $options = array()])
 string castNumeric (string $value, string $name, array &$stack, [array $options = array()])
 string castObject (object $value, string $name, array &$stack, [array $options = array()])
 string castString (string $value, string $name, array &$stack, [array $options = array()])
 bool commit ([array $options = array()])
 bool getCache (string $hash, array &$table, [array $options = array()])
 string getHash (string $query, [array $stack = array()], [array $options = array()])
 resource getLink ()
 mixed getOptions ([string $element = null])
 mixed lookup (string $element, [array $options = array()], [mixed $default = null])
 string push (mixed $value, string $name, array &$stack, [array $options = array()])
 bool rollback ([array $options = array()])
 int setCache (string $hash, array $table, [array $options = array()])
 mixed setOptions (mixed $options, [string $element = null])
 string strDecode (string $value, [array $options = array()])
 string strEncode (string $value, [array $options = array()])
 string strEscape (string $value, [array $options = array()])
 string strQuote (string $value, [array $options = array()])
 string strStrip (string $value, [array $options = array()])
 bool transaction ([array $options = array()])
Variables
array $cache = array() (line 71)
  • var: An associated array of cached query results.
  • access: protected
resource $conn (line 64)
  • var: The PHP database link identifier.
  • access: protected
array $options = array
(
self::CHAR_APPLICATION => "UTF-8",
self::CHAR_DATABASE => null,
self::LOG_DEBUG => false,
self::LOG_ERROR => true,
self::PARAM_CAST_NUMERIC => true,
self::PARAM_NAMED => false,
self::PARAM_PREFIX => "?",
self::PARAM_QUERIES => false,
self::PARAM_STRIP_TAGS => false,
self::PARAM_STRIP_MAGIC => false,
self::PARAM_TRIM => false,
self::RESULT_CACHE => true
// self::RESULT_LENGTH only allowed as a local select() option.
// self::RESULT_OFFSET only allowed as a local select() option.
// self::RESULT_KEY_FIELD only allowed as a local select() option.
)
(line 79)
  • var: Default values for all global options.
  • tutorial: Option elements
  • access: protected
Methods
Constructor BaseConnector (line 107)

Call this method from descendent constructors to set global options.

You can't create an instance of this class (it's abstract).

  • access: public
BaseConnector BaseConnector ([array $options = array()])
  • array $options: An associative array of options, see the Option elements.
bind (line 327)

Replace the query placeholders with matching parameter values or - if parameterized queries are enabled - the database specific placeholder.

Parameter values are converted, stripped, escaped, encoded and quoted according to the option values. The $stack returns an array of values for each placeholder to be used in parameterized queries.

  • return: The modified SQL query.
  • access: protected
string bind (string $query, array $param, [array &$stack = array()], [array $options = array()])
  • string $query: A SQL query string.
  • array $param: An associated array of values to replace the $query placeholders.
  • array &$stack: Returns an array of values for use in parameterized queries.
  • array $options: An associated array of options.
cast (line 386)

Cast a parameter to a valid SQL string or placeholder. The parameter is also pushed on the $stack - and if necessary converted - to be used in parameterized queries.

  • return: A valid SQL string or placeholder.
  • access: protected
string cast (mixed $value, string $name, array &$stack, [array $options = array()])
  • mixed $value: The parameter to replace the query placeholder.
  • string $name: The name of the query placeholder.
  • array &$stack: Push parameters on this array for use in parameterized queries.
  • array $options: An associated array of options.
castArray (line 602)

Arrays are converted to a comma separated list of values.

Strings are escaped and quoted. No placeholders are returend. Any arrays within the array are ignored. If the array is empty, the string "NULL" is returned.

  • return: A valid SQL string or placeholder.
  • access: protected
string castArray (array $list, string $name, array &$stack, [array $options = array()])
  • array $list: An array of parameter to replace the query placeholder.
  • string $name: The name of the query placeholder.
  • array &$stack: Parameters are pushed on this array for use in parameterized queries.
  • array $options: An associated array of options.
castBool (line 431)

Cast a boolean parameter to a valid SQL string or placeholder.

The parameter is also pushed on the $stack and converted to be used in parameterized queries.

  • return: A valid SQL string or placeholder.
  • access: protected
string castBool (bool $value, string $name, array &$stack, [array $options = array()])
  • bool $value: The parameter to replace the query placeholder.
  • string $name: The name of the query placeholder.
  • array &$stack: Parameters are pushed on this array for use in parameterized queries.
  • array $options: An associated array of options.
castDate (line 491)

Cast a DateTime parameter to a valid SQL string or placeholder.

The parameter is also pushed on the $stack to be used in parameterized queries.

  • return: A valid SQL string or placeholder.
  • access: protected
string castDate (DateTime $value, string $name, array &$stack, [array $options = array()])
  • DateTime $value: The parameter to replace the query placeholder.
  • string $name: The name of the query placeholder.
  • array &$stack: Parameters are pushed on this array for use in parameterized queries.
  • array $options: An associated array of options.
castFloat (line 471)

Cast a float parameter to a valid SQL string or placeholder.

The parameter is also pushed on the $stack to be used in parameterized queries.

  • return: A valid SQL string or placeholder.
  • access: protected
string castFloat (float $value, string $name, array &$stack, [array $options = array()])
  • float $value: The parameter to replace the query placeholder.
  • string $name: The name of the query placeholder.
  • array &$stack: Parameters are pushed on this array for use in parameterized queries.
  • array $options: An associated array of options.
castInt (line 451)

Cast an integer parameter to a valid SQL string or placeholder.

The parameter is also pushed on the $stack to be used in parameterized queries.

  • return: A valid SQL string or placeholder.
  • access: protected
string castInt (int $value, string $name, array &$stack, [array $options = array()])
  • int $value: The parameter to replace the query placeholder.
  • string $name: The name of the query placeholder.
  • array &$stack: Parameters are pushed on this array for use in parameterized queries.
  • array $options: An associated array of options.
castNull (line 411)

Cast null to a valid SQL string.

  • return: A valid SQL string.
  • access: protected
string castNull (null $value, string $name, array &$stack, [array $options = array()])
  • null $value: The parameter to replace the query placeholder.
  • string $name: The name of the query placeholder.
  • array &$stack: Push parameters on this array for use in parameterized queries.
  • array $options: An associated array of options.
castNumeric (line 517)

Cast a numeric string parameter to a valid SQL string or placeholder.

The parameter is also pushed on the $stack and converted to be used in parameterized queries.

  • return: A valid SQL string or placeholder.
  • access: protected
string castNumeric (string $value, string $name, array &$stack, [array $options = array()])
  • string $value: The parameter to replace the query placeholder.
  • string $name: The name of the query placeholder.
  • array &$stack: Parameters are pushed on this array for use in parameterized queries.
  • array $options: An associated array of options.
castObject (line 582)

With the exception of DataTime values, objects are not supported as parameters. Override this method to serialize your objects as SQL query strings.

  • return: A valid SQL string or placeholder.
  • access: protected
string castObject (object $value, string $name, array &$stack, [array $options = array()])
  • object $value: The parameter to replace the query placeholder.
  • string $name: The name of the query placeholder.
  • array &$stack: Parameters are pushed on this array for use in parameterized queries.
  • array $options: An associated array of options.
castString (line 552)

Cast a string parameter to a valid SQL string or placeholder.

The parameter is also pushed on the $stack and modified to be used in parameterized queries.

String values are converted, stripped, escaped, encoded and quoted according to the option values.

  • return: A valid SQL string or placeholder.
  • access: protected
string castString (string $value, string $name, array &$stack, [array $options = array()])
  • string $value: The parameter to replace the query placeholder.
  • string $name: The name of the query placeholder.
  • array &$stack: Parameters are pushed on this array for use in parameterized queries.
  • array $options: An associated array of options.

Redefined in descendants as:
commit (line 142)

Commits the current transaction on the current connection.

The current transaction includes all statements on the connection that were executed after the call to transaction() and before any calls to rollback() or commit().

  • return: true if the transaction was successfully committed, false otherwise.
  • see: IConnector::commit().
  • access: public
bool commit ([array $options = array()])

Implementation of:
IConnector::commit()
Commits the current transaction on the current connection.

Redefined in descendants as:
getCache (line 251)

Check if a maching query result exists in the result cache.

If true, set the $table argument to the cached query result, otherwise $table is set to an empty array.

  • return: true if a maching query result is found, false otherwise.
  • access: protected
bool getCache (string $hash, array &$table, [array $options = array()])
  • string $hash: A hash value of a query, see getHash().
  • array &$table: If found, return the cached query result, otherwise an empty array.
  • array $options: An associated array of options.
getHash (line 231)

Calculate the md5 hash value of the query string and - if necessary - the parameters of a parameterized query.

  • return: The md5 hash value.
  • access: protected
string getHash (string $query, [array $stack = array()], [array $options = array()])
  • string $query: The modified SQL query string after binding.
  • array $stack: An array of parameters to be used in a parameterized query.
  • array $options: An associated array of options.
getLink (line 170)

Get the database link identifier used by the IConnector instance.

  • return: A PHP database link identifier.
  • access: public
resource getLink ()

Implementation of:
IConnector::getLink()
Get the database link identifier used by the IConnector instance.
getOptions (line 184)

Get an array of all global options or the value of the global option defined in the optional $element parameter.

  • return: All options as an associated array or the value of a single option.
  • access: public
mixed getOptions ([string $element = null])

Implementation of:
IConnector::getOptions()
Get an array of all currently used options or the value of the option defined in the optional $element parameter.
lookup (line 295)

Get an option value. Any options in the local $options array overrides the global options.

  • return: The value of a single option.
  • access: protected
mixed lookup (string $element, [array $options = array()], [mixed $default = null])
  • string $element: An option constant, see the Option elements.
  • array $options: An associated array of options.
  • mixed $default: The default value to return if no global or local options are set.
push (line 357)

Push a parameter on the stack and return a query placeholder.

  • return: A valid SQL placeholder.
  • access: protected
string push (mixed $value, string $name, array &$stack, [array $options = array()])
  • mixed $value: The parameter to replace the query placeholder.
  • string $name: The name of the query placeholder.
  • array &$stack: Push parameters on this array for use in parameterized queries.
  • array $options: An associated array of options.
rollback (line 159)

Rolls back the current transaction on the current connection.

The current transaction includes all statements on the connection that were executed after the call to transaction() and before any calls to rollback() or commit().

  • return: true if the transaction was successfully rolled back, false otherwise.
  • see: IConnector::rollback().
  • access: public
bool rollback ([array $options = array()])

Implementation of:
IConnector::rollback()
Rolls back the current transaction on the current connection.

Redefined in descendants as:
setCache (line 275)

Add a new query result to the result cache.

  • return: The number of cached query results.
  • access: protected
int setCache (string $hash, array $table, [array $options = array()])
  • string $hash: A hash value of a query, see getHash().
  • array $table: The query result to cache.
  • array $options: An associated array of options.
setOptions (line 199)

Set one or more global options.

Some options are only valid as constructor or function parameters.

  • return: The previous option value(s).
  • access: public
mixed setOptions (mixed $options, [string $element = null])
  • mixed $options: Multiple options as an associated array or the value of a single option.
  • string $element: An option constant, see the Option elements.

Implementation of:
IConnector::setOptions()
Set one or more options for the IConnector instance.
strDecode (line 728)

Converts character encoding of from the character set of the database according to the current options.

  • return: The converted string.
  • access: protected
string strDecode (string $value, [array $options = array()])
  • string $value: The string that will be converted.
  • array $options: An associated array of options.
strEncode (line 686)

Converts character encoding of string parameters to the character set of the database according to the current options.

  • return: The converted string.
  • access: protected
string strEncode (string $value, [array $options = array()])
  • string $value: The string that will be converted.
  • array $options: An associated array of options.
strEscape (line 657)

Escape special characters in a string parameter.

  • return: The escaped string.
  • access: protected
string strEscape (string $value, [array $options = array()])
  • string $value: The string to be escaped.
  • array $options: An associated array of options.

Redefined in descendants as:
strQuote (line 671)

Add surrounding quotes to a string parameter.

  • return: The quoted string.
  • access: protected
string strQuote (string $value, [array $options = array()])
  • string $value: The string to be quoted.
  • array $options: An associated array of options.
strStrip (line 631)

Strip spare or insecure parts from a string parameter according to the current options.

  • return: The stripped string.
  • access: protected
string strStrip (string $value, [array $options = array()])
  • string $value: The string that will be stripped.
  • array $options: An associated array of options.
transaction (line 125)

Begins a transaction on the current connection.

The current transaction includes all statements on the connection that were executed after the call to transaction() and before any calls to rollback() or commit().

  • return: true if the transaction was successfully begun, false otherwise.
  • see: IConnector::transaction().
  • access: public
bool transaction ([array $options = array()])

Implementation of:
IConnector::transaction()
Begins a transaction on the current connection.

Redefined in descendants as:

Documentation generated on Wed, 03 Jun 2009 12:41:50 +0200 by phpDocumentor 1.4.1