nyroFwk  0.2
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()

__sleep ( )
inherited

Magic function to allow serialisation

Returns
array

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

◆ _beginTransaction()

_beginTransaction ( )
protectedinherited

Begin a transaction.

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

◆ _commit()

_commit ( )
protectedinherited

Commit a transaction.

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

◆ _connect()

_connect ( )
protectedinherited

Creates a connection to the database.

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

◆ _dsn()

_dsn ( )
protectedinherited

Create The dsn string for the connection.

Returns
string

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

◆ _rollBack()

_rollBack ( )
protectedinherited

Roll-back a transaction.

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

◆ afterInit()

afterInit ( )
protectedinherited

Call just after the configuration initialisation

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

◆ beforeInit()

beforeInit ( )
protectedinherited

Call just before the configuration initialisation

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

◆ beginTransaction()

beginTransaction ( )
inherited

Leave autocommit mode and begin a transaction.

Returns
bool True

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

◆ closeConnection()

closeConnection ( )
inherited

Force the connection to close.

Returns
void

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

◆ commit()

commit ( )
inherited

Commit a transaction and return to autocommit mode.

Returns
bool True

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

◆ count()

count ( array  $prm)
inherited

Count the number of result

Parameters
array$prmSame option than selectQuery
Returns
int
See also
selectQuery

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

◆ delete()

delete ( array  $prm)
inherited

Deletes table rows based on a WHERE clause.

Parameters
array$prmThe 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()

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 487 of file db/abstract.class.php.

◆ fetchPairs()

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 502 of file db/abstract.class.php.

◆ fetchRow()

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 515 of file db/abstract.class.php.

◆ fields()

fields (   $table)

Returns the properties

Parameters
string$tableTableName
Returns
array

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

◆ getAttr()

getAttr (   $name)
inherited

Get an attribute

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

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

◆ getCache()

getCache ( )
inherited

Get a cache instance

Returns
cache_abstract

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

◆ getCfg()

getCfg ( )
inherited

Get the configuration object

Returns
config

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

◆ getConnection()

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()

getFetchMode ( )
inherited

Get the fetch mode.

Returns
int

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

◆ getI18nTable()

getI18nTable (   $table)
inherited

Get the i18n tablename

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

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

◆ getInstanceCfg()

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()

getTables (   $unPrefix = true)

Returns a list of the tables in the database.

Parameters
boolean$unPrefixIndicate if the table name shold remove paramettred prefix
Returns
array

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

◆ getTablesWith()

getTablesWith ( array  $prm)
inherited

Returns a list of the tables with the parameters provided

Parameters
array$prmThe parameters for the search:
  • string start
  • string contains
  • string end
Returns
array

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

◆ getWhere()

getWhere ( array  $prm = array())
inherited

Get a where object

Parameters
array$prmThe configuration for the where object
Returns
db_where

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

◆ insert()

insert ( array  $prm)
inherited

Insert on the database

Parameters
array$prmThe 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()

lastInsertId ( )
inherited

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

Returns
string

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

◆ makeWhere()

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

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

Parameters
string | array$where
string$whereOpOperator (AND or OR)
bool$incWhereIndicates 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()

optimize (   $table)
inherited

Optimize a table

Parameters
string$tableThe table name

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

◆ prefixTable()

prefixTable (   $table)

Add a prefix that was previsouly removed for a table name

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

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

◆ prepare() [1/2]

prepare (   $sql,
array  $options = array() 
)
inherited

Prepare a statement and return a PDOStatement-like object.

Parameters
string$sqlSQL query
array$optionsDriver option
Returns
PDOStatement

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

◆ prepare() [2/2]

prepare (   $sql)
abstractinherited

Prepare a statement and return a PDOStatement.

Parameters
string | Zend_Db_Select$sqlSQL query
Returns
PDOStatement

◆ query()

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

Prepare and execute a query, with binding if provided

Parameters
string$sqlThe query to execute
Returns
PDOStatement

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

◆ quoteIdentifier()

quoteIdentifier (   $ident)
inherited

Quotes an identifier.

Parameters
string$identThe identifier.
Returns
string The quoted identifier.

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

◆ quoteValue()

quoteValue (   $value)
inherited

Quotes a value.

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

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

◆ replace()

replace ( array  $prm)
inherited

Replace on the database

Parameters
array$prmThe 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()

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()

select (   $prm)
inherited

Create a Select Query

Parameters
array | string$prmQuery 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 422 of file db/abstract.class.php.

◆ selectQuery()

selectQuery ( array  $prm)
inherited

Create a Select Query

Parameters
array$prmThe parameter for the select query :
  • array|string fields : The fields to select (default: *)
  • string table (required) : The table to work in
  • string moreTables : More table to select (string or array, if array, keys will be used as alias if non numeric)
  • 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
nExceptionif no table provided

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

◆ setAttr()

setAttr (   $name,
  $value 
)
inherited

Set an attribute

Parameters
string$nameAttribute name
mixed$valueAttribute value

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

◆ setFetchMode()

setFetchMode (   $mode)
inherited

Set the fetch mode.

Parameters
int$mode

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

◆ tableAlias()

tableAlias (   $query,
array  $tblAlias 
)
protectedinherited

Apply the table alias to a query

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

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

◆ update()

update ( array  $prm)
inherited

Update on the database

Parameters
array$prmThe 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

$cfg
protectedinherited

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

◆ $connection

$connection
protectedinherited

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

◆ $tables

$tables
protected

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


The documentation for this class was generated from the following file:
Generated on Sun Oct 15 2017 22:25:20 for nyroFwk by doxygen 1.8.13