Class jDbConnection

Description
  • abstract:

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


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

The database type name (mysql, pgsql ...)

  • access: public
mixed $lastQuery (line 55)

last executed query

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

The last error message if any

  • access: public
array $profile (line 38)

profile properties used by the connector

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

the internal connection.

  • access: protected
jDbSchema $_schema = null (line 345)
  • since: 1.2
  • access: protected
jDbTools $_tools = null (line 323)
  • since: 1.2
  • access: protected
Methods
beginTransaction (line 208)

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

validate all queries and close a transaction

  • abstract:
  • access: public
void commit ()

Redefined in descendants as:
Constructor __construct (line 72)

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 78)
void __destruct ()

Redefined in descendants as:
encloseFieldName (line 165)
void encloseFieldName ( $fieldName)
  • $fieldName
encloseName (line 157)

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

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

Redefined in descendants as:
exec (line 118)

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

Not implemented

  • return: the attribute value
  • access: public
string getAttribute (integer $id)
  • integer $id: the attribut id
hasTablePrefix (line 191)

Check if the current connection has a table prefix set

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

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

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

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

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

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

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

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

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

cancel all queries of a transaction and close the transaction

  • abstract:
  • access: public
void rollback ()

Redefined in descendants as:
schema (line 351)
  • since: 1.2
  • access: public
jDbSchema schema ()
setAttribute (line 257)

Not implemented

  • access: public
void setAttribute (integer $id, string $value)
  • integer $id: the attribut id
  • string $value: the attribute value
setAutoCommit (line 199)

sets the autocommit state

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

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

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

do a disconnection

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

  • abstract:
  • access: protected
void _disconnect ()

Redefined in descendants as:
_doExec (line 301)

do a query which return nothing

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

Redefined in descendants as:
_doLimitQuery (line 307)

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

do a query which return results

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

Redefined in descendants as:
_quote (line 315)

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_CURSOR = 10 (line 30)
ATTR_ERRMODE = 3 (line 29)
CURSOR_FWDONLY = 0 (line 31)
CURSOR_SCROLL = 1 (line 32)
FETCH_CLASS = 8 (line 26)
FETCH_INTO = 9 (line 27)
FETCH_OBJ = 5 (line 25)

Documentation generated on Thu, 19 Sep 2013 00:03:57 +0200 by phpDocumentor 1.4.3