Class jDbConnection

Description
  • abstract:

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


	
			
Direct descendents
Class Constant Summary
Variable Summary
Method Summary
void commit ()
jDbConnection __construct (array $profile)
void __destruct ()
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 55)

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

driver name

  • access: public
mixed $lastQuery (line 72)

last executed query

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

The last error message if any

  • access: public
array $profile (line 47)

profile properties used by the connector

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

the internal connection.

  • access: protected
mixed $_debugMode = false (line 85)
  • access: protected
jDbSchema $_schema = null (line 384)
  • since: 1.2
  • access: protected
jDbTools $_tools = null (line 363)
  • since: 1.2
  • access: protected
Methods
beginTransaction (line 246)

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

validate all queries and close a transaction

  • abstract:
  • access: public
void commit ()

Redefined in descendants as:
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 97)
void __destruct ()

Redefined in descendants as:
encloseName (line 203)

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 273)
  • return: the last error code
  • abstract:
  • access: public
integer errorCode ()

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

Redefined in descendants as:
exec (line 155)

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 289)
  • 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 229)

Check if the current connection has a table prefix set

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

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

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

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

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

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

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

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

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

cancel all queries of a transaction and close the transaction

  • abstract:
  • access: public
void rollback ()

Redefined in descendants as:
schema (line 390)
  • since: 1.2
  • access: public
jDbSchema schema ()
setAttribute (line 297)
  • 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 237)

sets the autocommit state

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

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

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

do a disconnection

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

  • abstract:
  • access: protected
void _disconnect ()

Redefined in descendants as:
_doExec (line 341)

do a query which return nothing

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

Redefined in descendants as:
_doLimitQuery (line 347)

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

do a query which return results

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

Redefined in descendants as:
_quote (line 355)

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 27)
ATTR_CASE = 8 (line 35)
ATTR_CLIENT_VERSION = 5 (line 33)
ATTR_CONNECTION_STATUS = 7 (line 34)
ATTR_CURSOR = 10 (line 36)
ATTR_DRIVER_NAME = 16 (line 39)
ATTR_ERRMODE = 3 (line 30)
ATTR_ORACLE_NULLS = 11 (line 37)
ATTR_PERSISTENT = 12 (line 38)
ATTR_PREFETCH = 1 (line 28)
ATTR_SERVER_INFO = 6 (line 32)
ATTR_SERVER_VERSION = 4 (line 31)
ATTR_TIMEOUT = 2 (line 29)
CURSOR_FWDONLY = 0 (line 40)
CURSOR_SCROLL = 1 (line 41)
FETCH_CLASS = 8 (line 25)
FETCH_INTO = 9 (line 26)
FETCH_OBJ = 5 (line 24)

Documentation generated on Wed, 04 Jan 2017 22:53:44 +0100 by phpDocumentor 1.4.3