Dotclear 2.24
Loading...
Searching...
No Matches
dbLayer Class Reference

Database Abstraction Layer class. More...

Inheritance diagram for dbLayer:
mysqliConnection pgsqlConnection sqliteConnection mysqlimb4Connection

Public Member Functions

 __construct (string $host, string $database, string $user='', string $password='', bool $persistent=false)
 
 close ()
 
 driver ()
 
 syntax ()
 
 version ()
 
 database ()
 
 link ()
 
 select (string $sql)
 
 nullRecord ()
 
 execute (string $sql)
 
 begin ()
 
 commit ()
 
 rollback ()
 
 writeLock (string $table)
 
 unlock ()
 
 vacuum (string $table)
 
 changes ()
 
 error ()
 
 dateFormat (string $field, string $pattern)
 
 limit ($arg1, ?int $arg2=null)
 
 in ($in)
 
 orderBy (... $args)
 
 lexFields (... $args)
 
 concat (... $args)
 
 escape ($i)
 
 escapeSystem (string $str)
 
 openCursor (string $table)
 

Static Public Member Functions

static init (string $driver, string $host, string $database, string $user='', string $password='', bool $persistent=false)
 

Protected Attributes

 $__driver
 
 $__syntax
 
 $__version
 string: Database version More...
 
 $__link
 
 $__last_result
 
 $__database
 

Detailed Description

Database Abstraction Layer class.

Base class for database abstraction. Each driver extends this class and implements i_dbLayer interface.

Constructor & Destructor Documentation

◆ __construct()

__construct ( string  $host,
string  $database,
string  $user = '',
string  $password = '',
bool  $persistent = false 
)
Parameters
string$hostDatabase hostname
string$databaseDatabase name
string$userUser ID
string$passwordPassword
bool$persistentPersistent connection

Member Function Documentation

◆ init()

static init ( string  $driver,
string  $host,
string  $database,
string  $user = '',
string  $password = '',
bool  $persistent = false 
)
static

Start connection

Static function to use to init database layer. Returns a object extending dbLayer.

Parameters
string$driverDriver name
string$hostDatabase hostname
string$databaseDatabase name
string$userUser ID
string$passwordPassword
bool$persistentPersistent connection
Returns
mixed

References exit.

Referenced by dcCore\__construct(), dcImportDC1\db(), and dcImportWP\db().

◆ close()

close ( )

Closes database connection.

◆ driver()

driver ( )

Returns database driver name

Returns
string

References $__driver.

◆ syntax()

syntax ( )

Returns database SQL syntax name

Returns
string

References $__syntax.

◆ version()

version ( )

Returns database driver version

Returns
string

References $__version.

◆ database()

database ( )

Returns current database name

Returns
string

References $__database.

◆ link()

link ( )

Returns link resource

Returns
mixed

References $__link.

◆ select()

select ( string  $sql)

Run query and get results

Executes a query and return a record object.

Parameters
string$sqlSQL query
Returns
record

Reimplemented in sqliteConnection.

Referenced by pgsqlConnection\callFunction().

◆ nullRecord()

nullRecord ( )

Return an empty record

Return an empty record object (without any information).

Returns
record

◆ execute()

execute ( string  $sql)

◆ begin()

begin ( )

Begin transaction

Begins a transaction. Transaction should be commited or rollbacked.

Reimplemented in sqliteConnection.

References execute().

◆ commit()

commit ( )

Commit transaction

Commits a previoulsy started transaction.

Reimplemented in sqliteConnection.

References execute().

◆ rollback()

rollback ( )

Rollback transaction

Rollbacks a previously started transaction.

Reimplemented in sqliteConnection.

References execute().

◆ writeLock()

writeLock ( string  $table)

Aquiere write lock

This method lock the given table in write access.

Parameters
string$tableTable name

◆ unlock()

unlock ( )

Release lock

This method releases an acquiered lock.

◆ vacuum()

vacuum ( string  $table)

Vacuum the table given in argument.

Parameters
string$tableTable name

Reimplemented in mysqliConnection, pgsqlConnection, and sqliteConnection.

◆ changes()

changes ( )

Changed rows

Returns the number of lines affected by the last DELETE, INSERT or UPDATE query.

Returns
int

◆ error()

error ( )

Last error

Returns the last database error or false if no error.

Returns
string|false

References $err.

◆ dateFormat()

dateFormat ( string  $field,
string  $pattern 
)

Date formatting

Returns a query fragment with date formater.

The following modifiers are accepted:

  • d : Day of the month, numeric
  • H : Hour 24 (00..23)
  • M : Minute (00..59)
  • m : Month numeric (01..12)
  • S : Seconds (00..59)
  • Y : Year, numeric, four digits
Parameters
string$fieldField name
string$patternDate format
Returns
string

Reimplemented in mysqliConnection, pgsqlConnection, and sqliteConnection.

References escape().

◆ limit()

limit (   $arg1,
?int  $arg2 = null 
)

Query Limit

Returns a LIMIT query fragment. $arg1 could be an array of offset and limit or an integer which is only limit. If $arg2 is given and $arg1 is an integer, it would become limit.

Parameters
array | int$arg1array or integer with limit intervals
int | null$arg2integer or null
Returns
string

◆ in()

in (   $in)

IN fragment

Returns a IN query fragment where $in could be an array, a string, an integer or null

Parameters
array | string | int | null$in"IN" values
Returns
string

References escape().

◆ orderBy()

orderBy (   $args)

ORDER BY fragment

Returns a ORDER BY query fragment where arguments could be an array or a string

array param: key : decription field : field name (string) collate : True or False (boolean) (Alphabetical order / Binary order) order : ASC or DESC (string) (Ascending order / Descending order)

string param field name (Binary ascending order)

Returns
string

Reimplemented in mysqliConnection, mysqlimb4Connection, pgsqlConnection, and sqliteConnection.

◆ lexFields()

lexFields (   $args)

Field name(s) fragment (using generic UTF8 collating sequence if available else using SQL LOWER function)

Returns a fields list where args could be an array or a string

array param: list of field names string param: field name

Returns
string

Reimplemented in mysqliConnection, mysqlimb4Connection, pgsqlConnection, and sqliteConnection.

◆ concat()

concat (   $args)

Concat strings

Returns SQL concatenation of methods arguments. Theses arguments should be properly escaped when needed.

Returns
string

Reimplemented in mysqliConnection.

◆ escape()

escape (   $i)

Escape string

Returns SQL protected string or array values.

Parameters
string | array$iString or array to protect
Returns
string|array

Referenced by pgsqlConnection\callFunction(), mysqliConnection\dateFormat(), pgsqlConnection\dateFormat(), sqliteConnection\dateFormat(), dateFormat(), sqliteConnection\escapeSystem(), and in().

◆ escapeSystem()

escapeSystem ( string  $str)

System escape string

Returns SQL system protected string.

Parameters
string$strString to protect
Returns
string

Reimplemented in mysqliConnection, and sqliteConnection.

Referenced by pgsqlConnection\db_write_lock(), and pgsqlConnection\vacuum().

◆ openCursor()

openCursor ( string  $table)

Cursor object

Returns a new instance of cursor class on $table for the current connection.

Parameters
string$tableTarget table
Returns
cursor

Field Documentation

◆ $__driver

$__driver
protected

Referenced by driver().

◆ $__syntax

$__syntax
protected

Referenced by syntax().

◆ $__version

$__version
protected

string: Database version

Referenced by version().

◆ $__link

$__link
protected

Referenced by link().

◆ $__last_result

$__last_result
protected

◆ $__database

$__database
protected

Referenced by database().


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