pclib  2.3.2
Lightweight PHP framework
Public Member Functions | Data Fields | Protected Attributes
AbstractDriver Class Reference

Base class for database driver. More...

Inheritance diagram for AbstractDriver:
MysqlDriver PdoDriver PgsqlDriver PdoMysqlDriver PdoSqliteDriver

Public Member Functions

 setLimit ($numRows, $offset=0)
 The portable way to perform limit. More...
 
 connect ($ds)
 Connect to database. More...
 
 close ()
 Close database connection. More...
 
 seek ($res, $rowno)
 Seek resource $res to position $rowno. More...
 
 getInsertId ()
 Return last insert id.
 
 numRows ($res=null)
 Return number of rows in result $res.
 
 affectedRows ($res=null)
 Return number of rows affected. More...
 
 query ($sql)
 Execute query $sql.
 
 fetch ($res=null, $fmt= 'a')
 Fetch one row from query result. More...
 
 lastError ()
 Return last driver error message.
 
 codePage ($cp)
 Set connection character set. More...
 
 dbName ()
 Return current database name.
 
 columns ($table)
 Return columns metadata (name,size,type,nullable,default) of table $table as associative array. More...
 
 indexes ($table)
 Return indexes of table $table as associative array.
 
 quote ($str)
 Quote identifier. More...
 
 escape ($str, $type= 'string')
 Escape parameters for usage in database query. More...
 

Data Fields

 $connection
 Active database connection link. More...
 
 $error
 Contains last error message - test it after calling any db-function to check if any error occurs.
 
 $res
 Store last query result resource. More...
 
 $forceReconnect = true
 Create new connection even if connection with same params exists.
 
 $extension
 Required PHP extension - such as 'mysql'. More...
 
 $verboseErrors = false
 Include internal details (such as SQL code) into error messages. More...
 

Protected Attributes

 $limit
 Store portable limit clausule.
 

Detailed Description

Base class for database driver.

Any database driver must implement this class. Database drivers are stored in pclib/system/database/ directory and loaded by class Db automatically.

Member Function Documentation

affectedRows (   $res = null)
abstract

Return number of rows affected.

close ( )
abstract

Close database connection.

codePage (   $cp)
abstract

Set connection character set.

Parameters
string$cpcodepage - e.g. 'cp1250'
columns (   $table)
abstract

Return columns metadata (name,size,type,nullable,default) of table $table as associative array.

Returns
array $columns
connect (   $ds)
abstract

Connect to database.

Parameters
array$dsdatasource: array( 'driver' => $driver, 'host' => $host, 'dbname' => $dbname, 'user' => $user, 'passw' => $passw, 'codepage' => $codepage );
escape (   $str,
  $type = 'string' 
)
abstract

Escape parameters for usage in database query.

Parameters
string$strString (parameter) to be escaped
string$typeCan be 'string' or 'ident'
Returns
string $str escaped string
fetch (   $res = null,
  $fmt = 'a' 
)
abstract

Fetch one row from query result.

If result $res is ommited, it uses last query result.

Parameters
resource$resQuery result resource
string$fmtformat of result a - assoc, o - object, r - row, ar - array, f - field
Returns
array|object $row result row
quote (   $str)
abstract

Quote identifier.

seek (   $res,
  $rowno 
)
abstract

Seek resource $res to position $rowno.

setLimit (   $numRows,
  $offset = 0 
)

The portable way to perform limit.

Next query result will be limited according setLimit parameters.

Parameters
int$numRowsNumber of rows returned
int$offsetOffset from start

Field Documentation

$connection

Active database connection link.

$extension

Required PHP extension - such as 'mysql'.

$res

Store last query result resource.

Type: resource

$verboseErrors = false

Include internal details (such as SQL code) into error messages.


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