Class ActiveRecord_Connection_Default

Description

Default implementation of ActiveRecord_Connection

Located in /activerecord/lib/ActiveRecord/Connection/Default.php (line 14)

PDO
   |
   --ActiveRecord_Connection
      |
      --ActiveRecord_Connection_Default
Direct descendents
Class Description
 class ActiveRecord_Connection_Mysql ActiveRecordConnection for MySQL
 class ActiveRecord_Connection_Sqlite ActiveRecord_Connection for SQLite
Method Summary
 ActiveRecord_Connection_Default __construct (string $dsn, [string $username = NULL], [string $password = NULL], [array $options = NULL])
 string addLimit ( $sql, [int $limit = -1], [int $offset = 1])
 array columns (string $table)
 string defaultSequenceName (string $table, string $key)
 mixed nextSequenceValue (string $name)
 bool prefetchPrimaryKey (string $table)
 string quoteBoundValue (mixed $value)
 string sanitizeSQL (mixed $sql)
 array tables ()
Methods
Constructor __construct (line 25)

Constructor

Do not call this method directly. Call ActiveRecord_Connection::create instead.

  • access: public
ActiveRecord_Connection_Default __construct (string $dsn, [string $username = NULL], [string $password = NULL], [array $options = NULL])
  • string $dsn: The data source name
  • string $username: The user name for the DSN string (optional)
  • string $password: The password for the DSN string (optional)
  • array $options: An array of options as allowed by PDO (optional)

Redefinition of:
ActiveRecord_Connection::__construct()
Constructor

Redefined in descendants as:
addLimit (line 81)

Append a LIMIT clause to a SQL statement

  • access: public
string addLimit ( $sql, [int $limit = -1], [int $offset = 1])
  • int $limit: The maximum number of rows to return (or -1 for no maximum)
  • int $offset: The first row number to return in the results (e.g. 1 to return all rows, 2 to skip the first row)
  • $sql

Redefinition of:
ActiveRecord_Connection::addLimit()
Append a LIMIT clause to a SQL statement

Redefined in descendants as:
columns (line 98)

Return an array of ActiveRecord_Column objects for the named table.

  • access: public
array columns (string $table)
  • string $table: The name of the table to return the columns for

Redefinition of:
ActiveRecord_Connection::columns()
Return an array of ActiveRecordColumn objects for the named table.

Redefined in descendants as:
defaultSequenceName (line 123)

Return the sequence name that would be used to generated the

next value for the named key on the given table. Even if this connection does not support sequences or the resulting sequence does not exist, the name of what that sequence would be is returned.

  • access: public
string defaultSequenceName (string $table, string $key)
  • string $table: The name of the table to generate the sequence name for
  • string $key: The name of the key on that table to generate the name for

Redefinition of:
ActiveRecord_Connection::defaultSequenceName()
Return the sequence name that would be used to generated the
nextSequenceValue (line 169)

Returns the next value from the named sequence. This function throws ActiveRecord_SequencesNotSupportedError if the connection does not support sequences.

  • access: public
mixed nextSequenceValue (string $name)
  • string $name: The name of the sequence

Redefinition of:
ActiveRecord_Connection::nextSequenceValue()
Returns the next value from the named sequence. This function throws ActiveRecord_SequencesNotSupportedError if the connection does not support sequences.
prefetchPrimaryKey (line 156)

Used to test whether this connection uses sequences to generate

primary keys for the given table. If a new primary key value should be fetched prior to inserting a new record into the named table, true is returned. Otherwise false is returned, and the caller can assume it is safe to invoke lastInsertId following the execution of the insert statement.

  • access: public
bool prefetchPrimaryKey (string $table)
  • string $table: The name of the table to test

Redefinition of:
ActiveRecord_Connection::prefetchPrimaryKey()
Used to test whether this connection uses sequences to generate
quoteBoundValue (line 69)

Quote a value for use by sanitizeSQL

  • access: protected
string quoteBoundValue (mixed $value)
  • mixed $value: The value to quote
sanitizeSQL (line 55)

Accepts a string or array containing an SQL statement or

fragment an performs parameter substitution. When a string is provided, it is returned verbatim, however, when an array is provide, is is assumed that the first item in the array is the SQL statement (or fragment) containing parameter placeholders (in the form of question marks) and that all subsequent items in the array are ordered parameters to be used for substituion.

For example, passing in the following:

  1.    sanitizeSQL(array("status=? AND last_name LIKE ?"'Active''%Smith%'))
Would return this string:
  1.    "status='Active' AND last_name LIKE '%Smith%'"

Of course, this is actually more useful when passing in variables with unknown values as the parameters instead of literals, since sanitizeSQL handles any necessary escaping of the values.

  • access: public
string sanitizeSQL (mixed $sql)
  • mixed $sql: The string or array to sanitize

Redefinition of:
ActiveRecord_Connection::sanitizeSQL()
Accepts a string or array containing an SQL statement or
tables (line 132)

Returns an array of table names in the database

  • access: public
array tables ()

Redefinition of:
ActiveRecord_Connection::tables()
Returns an array of table names in the database

Redefined in descendants as:

Inherited Methods

Inherited From ActiveRecord_Connection

 ActiveRecord_Connection::__construct()
 ActiveRecord_Connection::addLimit()
 ActiveRecord_Connection::columns()
 ActiveRecord_Connection::create()
 ActiveRecord_Connection::defaultSequenceName()
 ActiveRecord_Connection::nextSequenceValue()
 ActiveRecord_Connection::prefetchPrimaryKey()
 ActiveRecord_Connection::sanitizeSQL()
 ActiveRecord_Connection::selectAll()
 ActiveRecord_Connection::selectValue()
 ActiveRecord_Connection::tables()

Documentation generated on Wed, 25 Apr 2012 09:46:42 -0700 by phpDocumentor 1.4.3