Class jDbConnection

Description
  • abstract:

Located in /db/jDbConnection.class.php (line 23)


	
			
Direct descendents
Class Constant Summary
Variable Summary
Method Summary
jDbConnection __construct (array $profile)
void __destruct ()
void commit ()
void encloseFieldName ( $fieldName)
string encloseName (string $fieldName)
integer errorCode ()
string errorInfo ()
integer exec (string $query)
string getAttribute (integer $id)
boolean hasTablePrefix ()
integer lastIdInTable (string $fieldName, string $tableName)
integer lastInsertId ([string $fromSequence = ''])
jDbResultSet|boolean limitQuery (string $queryString, integer $limitOffset, integer $limitCount)
string prefixTable ( $table_name, string $table)
statement prepare (string $query)
jDbResultSet|boolean query (string $queryString, [integer $fetchmode = self::FETCH_OBJ], [ $arg1 = null], [array $ctoargs = null], string|object $param)
string quote (string $text, [int $parameter_type = 0])
string quote2 (string $text, [boolean $checknull = true], [boolean $binary = false])
void rollback ()
void setAttribute (integer $id, string $value)
void setAutoCommit ([boolean $state = true])
void _autoCommitNotify (boolean $state)
integer _connect ()
void _disconnect ()
jDbResultSet/boolean _doExec ( $queryString)
jDbResultSet/boolean _doLimitQuery ( $queryString,  $offset,  $number)
jDbResultSet/boolean _doQuery ( $queryString)
void _quote (string $text, boolean $binary)
Variables
string $dbms (line 56)

The database type name (mysql, pgsql ...) It is not the driver name. Several drivers could connect to the same database type. This type name is often used to know whish SQL language we should use.

  • access: public
string $driverName = '' (line 62)

driver name

  • access: public
mixed $lastQuery (line 73)

last executed query

  • access: public
string $msgError = '' (line 68)

The last error message if any

  • access: public
array $profile (line 48)

profile properties used by the connector

  • access: public
mixed $_connection = null (line 84)

the internal connection.

  • access: protected
jDbSchema $_schema = null (line 376)
  • since: 1.2
  • access: protected
jDbTools $_tools = null (line 355)
  • since: 1.2
  • access: protected
Methods
Constructor __construct (line 90)

do a connection to the database, using properties of the given profile

jDbConnection __construct (array $profile)
  • array $profile: profile properties

Redefined in descendants as:
Destructor __destruct (line 96)
void __destruct ()

Redefined in descendants as:
beginTransaction (line 238)

begin a transaction. Call it before query, limitQuery, exec

And then commit() or rollback()

  • abstract:
  • access: public
void beginTransaction ()

Redefined in descendants as:
commit (line 243)

validate all queries and close a transaction

  • abstract:
  • access: public
void commit ()

Redefined in descendants as:
encloseFieldName (line 195)
void encloseFieldName ( $fieldName)
  • $fieldName
encloseName (line 187)

enclose the field name

  • return: the enclosed field name
  • since: 1.1.1
  • access: public
string encloseName (string $fieldName)
  • string $fieldName: the field name

Redefined in descendants as:
errorCode (line 265)
  • return: the last error code
  • abstract:
  • access: public
integer errorCode ()

Redefined in descendants as:
errorInfo (line 260)
  • return: the last error description
  • abstract:
  • access: public
string errorInfo ()

Redefined in descendants as:
exec (line 144)

Launch a SQL Query (update, delete..) which doesn't return rows

  • return: the number of affected rows. False if the query has failed.
  • access: public
integer exec (string $query)
  • string $query: the SQL query
getAttribute (line 281)
  • return: the attribute value
  • see: PDO::getAttribute()
  • abstract:
  • access: public
string getAttribute (integer $id)
  • integer $id: the attribut id

Redefined in descendants as:
hasTablePrefix (line 221)

Check if the current connection has a table prefix set

  • author: Julien Issler
  • since: 1.0
  • access: public
boolean hasTablePrefix ()
lastIdInTable (line 297)

return the maximum value of the given primary key in a table

  • return: the maximum value
  • access: public
integer lastIdInTable (string $fieldName, string $tableName)
  • string $fieldName: the name of the primary key
  • string $tableName: the name of the table
lastInsertId (line 273)

return the id value of the last inserted row.

Some driver need a sequence name, so give it at first parameter

  • return: the id value
  • abstract:
  • access: public
integer lastInsertId ([string $fromSequence = ''])
  • string $fromSequence: the sequence name

Redefined in descendants as:
limitQuery (line 129)

Launch a SQL Query with limit parameter, so it returns only a subset of a result

  • return: SQL Select. False if the query has failed.
  • access: public
jDbResultSet|boolean limitQuery (string $queryString, integer $limitOffset, integer $limitCount)
  • string $queryString: the SQL query
  • integer $limitOffset: the offset of the first row to return
  • integer $limitCount: the maximum of number of rows to return
prefixTable (line 208)

Prefix the given table with the prefix specified in the connection's profile If there's no prefix for the connection's profile, return the table's name unchanged.

  • return: the prefixed table's name
  • author: Julien Issler
  • since: 1.0
  • access: public
string prefixTable ( $table_name, string $table)
  • string $table: the table's name
  • $table_name
prepare (line 255)

prepare a query

  • return: a statement
  • abstract:
  • access: public
statement prepare (string $query)
  • string $query: a sql query with parameters

Redefined in descendants as:
query (line 110)

Launch a SQL Query which returns rows (typically, a SELECT statement)

  • return: False if the query has failed.
  • access: public
jDbResultSet|boolean query (string $queryString, [integer $fetchmode = self::FETCH_OBJ], [ $arg1 = null], [array $ctoargs = null], string|object $param)
  • string $queryString: the SQL query
  • integer $fetchmode: FETCH_OBJ, FETCH_CLASS or FETCH_INTO
  • string|object $param: class name if FETCH_CLASS, an object if FETCH_INTO. else null.
  • array $ctoargs: arguments for the constructor if FETCH_CLASS
  • $arg1
quote (line 159)

Escape and quotes strings.

  • return: escaped string
  • access: public
string quote (string $text, int $parameter_type)
  • string $text: string to quote
  • int $parameter_type: unused, just for compatibility with PDO
quote2 (line 174)

Escape and quotes strings. if null, will only return the text "NULL"

  • return: escaped string
  • since: 1.2
  • access: public
string quote2 (string $text, [boolean $checknull = true], [boolean $binary = false])
  • string $text: string to quote
  • boolean $checknull: if true, check if $text is a null value, and then return NULL
  • boolean $binary: set to true if $text contains a binary string
rollback (line 248)

cancel all queries of a transaction and close the transaction

  • abstract:
  • access: public
void rollback ()

Redefined in descendants as:
schema (line 382)
  • since: 1.2
  • access: public
jDbSchema schema ()
setAttribute (line 289)
  • see: PDO::setAttribute()
  • abstract:
  • access: public
void setAttribute (integer $id, string $value)
  • integer $id: the attribut id
  • string $value: the attribute value

Redefined in descendants as:
setAutoCommit (line 229)

sets the autocommit state

  • access: public
void setAutoCommit ([boolean $state = true])
  • boolean $state: the status of autocommit
tools (line 361)
  • since: 1.2
  • access: public
jDbTools tools ()
_autoCommitNotify (line 310)

Notify the changes on autocommit

Drivers may overload this

  • abstract:
  • access: protected
void _autoCommitNotify (boolean $state)
  • boolean $state: the new state of autocommit

Redefined in descendants as:
_connect (line 316)

return a connection identifier or false/null if there is an error

  • return: connection identifier
  • abstract:
  • access: protected
integer _connect ()

Redefined in descendants as:
_disconnect (line 322)

do a disconnection

(no need to do a test on the connection id)

  • abstract:
  • access: protected
void _disconnect ()

Redefined in descendants as:
_doExec (line 333)

do a query which return nothing

  • abstract:
  • access: protected
jDbResultSet/boolean _doExec ( $queryString)
  • $queryString

Redefined in descendants as:
_doLimitQuery (line 339)

do a query which return a limited number of results

  • abstract:
  • access: protected
jDbResultSet/boolean _doLimitQuery ( $queryString,  $offset,  $number)
  • $queryString
  • $offset
  • $number

Redefined in descendants as:
_doQuery (line 328)

do a query which return results

  • abstract:
  • access: protected
jDbResultSet/boolean _doQuery ( $queryString)
  • $queryString

Redefined in descendants as:
_quote (line 347)

do the escaping of a string.

you should override it into the driver

  • access: protected
void _quote (string $text, boolean $binary)
  • string $text: the text to escape
  • boolean $binary: true if the content of the string is a binary content

Redefined in descendants as:
Class Constants
ATTR_AUTOCOMMIT = 0 (line 28)
ATTR_CASE = 8 (line 36)
ATTR_CLIENT_VERSION = 5 (line 34)
ATTR_CONNECTION_STATUS = 7 (line 35)
ATTR_CURSOR = 10 (line 37)
ATTR_DRIVER_NAME = 16 (line 40)
ATTR_ERRMODE = 3 (line 31)
ATTR_ORACLE_NULLS = 11 (line 38)
ATTR_PERSISTENT = 12 (line 39)
ATTR_PREFETCH = 1 (line 29)
ATTR_SERVER_INFO = 6 (line 33)
ATTR_SERVER_VERSION = 4 (line 32)
ATTR_TIMEOUT = 2 (line 30)
CURSOR_FWDONLY = 0 (line 41)
CURSOR_SCROLL = 1 (line 42)
FETCH_CLASS = 8 (line 26)
FETCH_INTO = 9 (line 27)
FETCH_OBJ = 5 (line 25)

Documentation generated on Mon, 26 Oct 2015 21:53:12 +0100 by phpDocumentor 1.4.3