Public Member Functions | Protected Member Functions | Protected Attributes

db_pdo_mysql Class Reference

Inheritance diagram for db_pdo_mysql:
db_pdo_abstract db_abstract object

Public Member Functions

 getTables ($unPrefix=true)
 prefixTable ($table)
 fields ($table)
 closeConnection ()
 prepare ($sql, array $options=array())
 prepare ($sql)
 lastInsertId ()
 getInstanceCfg ()
 getConnection ()
 query ($sql, array $bind=array())
 beginTransaction ()
 commit ()
 rollBack ()
 insert (array $prm)
 replace (array $prm)
 update (array $prm)
 delete (array $prm)
 makeWhere ($where, $whereOp='AND', $incWhere=true)
 getFetchMode ()
 setFetchMode ($mode)
 selectQuery (array $prm)
 select ($prm)
 count (array $prm)
 fetchAssoc (array $prm)
 fetchPairs (array $prm)
 fetchRow (array $prm)
 quoteIdentifier ($ident)
 quoteValue ($value)
 optimize ($table)
 getTablesWith (array $prm)
 getI18nTable ($table)
 getWhere (array $prm=array())
 getCache ()
 __sleep ()
 getAttr ($name)
 setAttr ($name, $value)
 getCfg ()

Protected Member Functions

 _connect ()
 _dsn ()
 _beginTransaction ()
 _commit ()
 _rollBack ()
 tableAlias ($query, array $tblAlias)
 beforeInit ()
 afterInit ()

Protected Attributes

 $tables
 $connection
 $cfg

Detailed Description

Interface for db classes

Definition at line 10 of file mysql.class.php.


Member Function Documentation

__sleep (  )  [inherited]

Magic function to allow serialisation

Returns:
array

Definition at line 613 of file db/abstract.class.php.

_beginTransaction (  )  [protected, inherited]

Begin a transaction.

Reimplemented from db_abstract.

Definition at line 81 of file db/pdo/abstract.class.php.

_commit (  )  [protected, inherited]

Commit a transaction.

Reimplemented from db_abstract.

Definition at line 89 of file db/pdo/abstract.class.php.

_connect (  )  [protected, inherited]

Creates a connection to the database.

Reimplemented from db_abstract.

Definition at line 22 of file db/pdo/abstract.class.php.

_dsn (  )  [protected, inherited]

Create The dsn string for the connection.

Returns:
string

Definition at line 43 of file db/pdo/abstract.class.php.

_rollBack (  )  [protected, inherited]

Roll-back a transaction.

Reimplemented from db_abstract.

Definition at line 97 of file db/pdo/abstract.class.php.

beforeInit (  )  [protected, inherited]

Call just before the configuration initialisation

Reimplemented in form_file.

Definition at line 35 of file object.class.php.

beginTransaction (  )  [inherited]

Leave autocommit mode and begin a transaction.

Returns:
bool True

Definition at line 58 of file db/abstract.class.php.

closeConnection (  )  [inherited]

Force the connection to close.

Returns:
void

Reimplemented from db_abstract.

Definition at line 52 of file db/pdo/abstract.class.php.

commit (  )  [inherited]

Commit a transaction and return to autocommit mode.

Returns:
bool True

Definition at line 69 of file db/abstract.class.php.

count ( array $  prm  )  [inherited]

Count the number of result

Parameters:
array $prm Same option than selectQuery
Returns:
int
See also:
selectQuery

Definition at line 446 of file db/abstract.class.php.

delete ( array $  prm  )  [inherited]

Deletes table rows based on a WHERE clause.

Parameters:
array $prm The parameter for the replace query :

  • string table (required) : The table to work in
  • db_where|array|string where : The where clause. If array, they are used with AND. (default: none)
  • string whereOp : The operator for the where clause if it's an array (default: AND)
  • bool optim : Make an optimization after the delete (default: true)
Returns:
int Deleted rows

Definition at line 180 of file db/abstract.class.php.

fetchAssoc ( array $  prm  )  [inherited]

Fetches all SQL result rows as an associative array. Same parameter as select.

The first column is the key, the entire row array is the value. You should construct the query to be sure that the first column contains unique values, or else rows with duplicate values in the first column will overwrite previous data.

Parameters:
array $prm: same as select
Returns:
array
See also:
select

Definition at line 471 of file db/abstract.class.php.

fetchPairs ( array $  prm  )  [inherited]

Fetches all SQL result rows as an array of key-value pairs.

The first column is the key, the second column is the value.

Parameters:
array $prm: same as select.
Returns:
array
See also:
select

Definition at line 486 of file db/abstract.class.php.

fetchRow ( array $  prm  )  [inherited]

Fetches the first row of the SQL result. Uses the current fetchMode for the adapter.

Parameters:
array $prm: same as select.
Returns:
array
See also:
select

Definition at line 499 of file db/abstract.class.php.

fields ( table  ) 

Returns the properties

Parameters:
string $table TableName
Returns:
array

Reimplemented from db_abstract.

Definition at line 64 of file mysql.class.php.

getAttr ( name  )  [inherited]

Get an attribute

Parameters:
string $name Attribute name
Returns:
mixed|null The attribute or null if not set

Reimplemented in response_proxy.

Definition at line 48 of file object.class.php.

getCache (  )  [inherited]

Get a cache instance

Returns:
cache_abstract

Definition at line 604 of file db/abstract.class.php.

getCfg (  )  [inherited]

Get the configuration object

Returns:
config

Definition at line 67 of file object.class.php.

getConnection (  )  [inherited]

Returns the connection object, ressource. Initialize the connection if need.

Returns:
object|resource|null

Definition at line 34 of file db/abstract.class.php.

getFetchMode (  )  [inherited]

Get the fetch mode.

Returns:
int

Definition at line 236 of file db/abstract.class.php.

getI18nTable ( table  )  [inherited]

Get the i18n tablename

Parameters:
string $table table name
Returns:
string|null The i18n tablename or null if not found

Definition at line 578 of file db/abstract.class.php.

getInstanceCfg (  )  [inherited]

Get the configuration parameter used to create this object

Returns:
string|array

Definition at line 24 of file db/abstract.class.php.

getTables ( unPrefix = true  ) 

Returns a list of the tables in the database.

Parameters:
boolean $unPrefix Indicate if the table name shold remove paramettred prefix
Returns:
array

Reimplemented from db_abstract.

Definition at line 25 of file mysql.class.php.

getTablesWith ( array $  prm  )  [inherited]

Returns a list of the tables with the parameters provided

Parameters:
array $prm The parameters for the search:

  • string start
  • string contains
  • string end
Returns:
array

Definition at line 554 of file db/abstract.class.php.

getWhere ( array $  prm = array()  )  [inherited]

Get a where object

Parameters:
array $prm The configuration for the where object
Returns:
db_where

Definition at line 593 of file db/abstract.class.php.

insert ( array $  prm  )  [inherited]

Insert on the database

Parameters:
array $prm The parameter for the insert query :

  • string table (required) : The table to work in
  • array values (required) : The values to insert. The key are the identifier
Returns:
mixed the inserted id

Definition at line 94 of file db/abstract.class.php.

lastInsertId (  )  [inherited]

Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.

Returns:
string

Reimplemented from db_abstract.

Definition at line 73 of file db/pdo/abstract.class.php.

makeWhere ( where,
whereOp = 'AND',
incWhere = true 
) [inherited]

Make a where clause from a where parameter (select, update or delete)

Parameters:
string|array $where
string $whereOp Operator (AND or OR)
bool $incWhere Indicates if the WHERE keywords should be included at the beginning
Returns:
null|string the where string, starting with WHERE

Definition at line 210 of file db/abstract.class.php.

optimize ( table  )  [inherited]

Optimize a table

Parameters:
string $table The table name

Definition at line 541 of file db/abstract.class.php.

prefixTable ( table  ) 

Add a prefix that was previsouly removed for a table name

Parameters:
string $table Table name
Returns:
string Table name with it's prefix, if existing

Reimplemented from db_abstract.

Definition at line 48 of file mysql.class.php.

prepare ( sql  )  [abstract, inherited]

Prepare a statement and return a PDOStatement.

Parameters:
string|Zend_Db_Select $sql SQL query
Returns:
PDOStatement
prepare ( sql,
array $  options = array() 
) [inherited]

Prepare a statement and return a PDOStatement-like object.

Parameters:
string $sql SQL query
array $options Driver option
Returns:
PDOStatement

Definition at line 63 of file db/pdo/abstract.class.php.

query ( sql,
array $  bind = array() 
) [inherited]

Prepare and execute a query, with binding if provided

Parameters:
string $sql The query to execute
Returns:
PDOStatement

Definition at line 45 of file db/abstract.class.php.

quoteIdentifier ( ident  )  [inherited]

Quotes an identifier.

Parameters:
string $ident The identifier.
Returns:
string The quoted identifier.

Definition at line 511 of file db/abstract.class.php.

quoteValue ( value  )  [inherited]

Quotes a value.

Parameters:
string $value The value.
Returns:
string The quoted value.

Definition at line 532 of file db/abstract.class.php.

replace ( array $  prm  )  [inherited]

Replace on the database

Parameters:
array $prm The parameter for the replace query :

  • string table (required) : The table to work in
  • array values (required) : The values to replace. The key are the identifier
Returns:
mixed the inserted id

Definition at line 120 of file db/abstract.class.php.

rollBack (  )  [inherited]

Roll back a transaction and return to autocommit mode.

Returns:
bool True

Definition at line 80 of file db/abstract.class.php.

select ( prm  )  [inherited]

Create a Select Query

Parameters:
array|string $prm Query as string or array: The parameter for the select query (
See also:
selectQuery) and plus:
  • int result : The result type MYSQL_ASSOC, MYSQL_NUM or MYSQL_BOTH (default: MYSQL_BOTH)
Returns:
array Numeric array. Each line is one result

Definition at line 406 of file db/abstract.class.php.

selectQuery ( array $  prm  )  [inherited]

Create a Select Query

Parameters:
array $prm The parameter for the select query :

  • array|string fields : The fields to select (default: *)
  • string table (required) : The table to work in
  • array join : tables to join. Keys are:
    • string table (required) : table to join
    • string dir: how to join (default: 'left')
    • string on: on Clause to join the table (default: 1)
    • string alias: table alias (default: none)
  • array bind : Data to bind
  • bool bindData : Bind the data inside the query
  • db_where|array|string where : The where clause. If array, they are used with AND. (default: none)
  • string whereOp : The operator for the where clause if it's an array (default: AND)
  • string order : The order clause (default: none)
  • int start : The select start (default: 0)
  • int nb : The select limit (default: unlimited)
  • string group : The group clause (default: none)
  • string groupAfter : The group clause to be done after everything else (useful for order grouping queries) (default: none)
  • string having : The having clause (default: none)
Returns:
string The select query
Exceptions:
nException if no table provided

Definition at line 273 of file db/abstract.class.php.

setAttr ( name,
value 
) [inherited]

Set an attribute

Parameters:
string $name Attribute name
mixed $value Attribute value

Reimplemented in response_proxy.

Definition at line 58 of file object.class.php.

setFetchMode ( mode  )  [inherited]

Set the fetch mode.

Parameters:
int $mode

Definition at line 245 of file db/abstract.class.php.

tableAlias ( query,
array $  tblAlias 
) [protected, inherited]

Apply the table alias to a query

Parameters:
string $query The query
array $tblAlias The alias (keys: tablenames, values: aliases)
Returns:
string The query with the aliases applied

Definition at line 381 of file db/abstract.class.php.

update ( array $  prm  )  [inherited]

Update on the database

Parameters:
array $prm The parameter for the replace query :

  • string table (required) : The table to work in
  • array values (required) : The values to update. A string index array: index are the field
  • db_where|array|string where : The where clause. If array, they are used with AND. (default: none)
  • string whereOp : The operator for the where clause if it's an array (default: AND)
Returns:
int Affected rows (Can return 0 if no change)
Exceptions:
nException 

Definition at line 149 of file db/abstract.class.php.


Field Documentation

$cfg [protected, inherited]

Definition at line 17 of file object.class.php.

$connection [protected, inherited]

Reimplemented from db_abstract.

Definition at line 17 of file db/pdo/abstract.class.php.

$tables [protected]

Definition at line 17 of file mysql.class.php.


The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables Enumerations
Generated on Tue May 8 2012 16:02:25 for nyroFwk by doxygen 1.7.1