Class jDbConnection

Description
  • abstract:

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


	
			
Direct descendents
Class Constant Summary
Variable Summary
mixed $dbms
mixed $lastQuery
string $msgError
array $profile
mixed $_connection
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 ()
void lastIdInTable ( $fieldName,  $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, [boolean $checknull = true], [ $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
mixed $dbms (line 43)

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

  • access: public
mixed $lastQuery (line 54)

last executed query

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

The last error message if any

  • access: public
array $profile (line 38)

profile properties used by the connector

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

the internal connection.

  • access: protected
Methods
Constructor __construct (line 71)

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

Redefined in descendants as:
beginTransaction (line 194)

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

validate all queries and close a transaction

  • abstract:
  • access: public
void commit ()

Redefined in descendants as:
encloseFieldName (line 151)
void encloseFieldName ( $fieldName)
  • $fieldName
encloseName (line 143)

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

Redefined in descendants as:
errorInfo (line 216)
  • 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 236)

Not implemented

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

Check if the current connection has a table prefix set

  • author: Julien Issler
  • since: 1.0
  • access: public
boolean hasTablePrefix ()
lastIdInTable (line 248)
  • access: public
void lastIdInTable ( $fieldName,  $tableName)
  • $fieldName
  • $tableName
lastInsertId (line 229)

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

Launch a SQL Query with limit parameter (so 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 164)

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

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

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

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

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

cancel all queries of a transaction and close the transaction

  • abstract:
  • access: public
void rollback ()

Redefined in descendants as:
setAttribute (line 243)

Not implemented

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

sets the autocommit state

  • access: public
void setAutoCommit ([boolean $state = true])
  • boolean $state: state the status of autocommit
_autoCommitNotify (line 261)

Notify the changes on autocommit

Drivers may overload this

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

Redefined in descendants as:
_connect (line 267)

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

do a disconnection

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

  • abstract:
  • access: protected
void _disconnect ()

Redefined in descendants as:
_doExec (line 284)

do a query which return nothing

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

Redefined in descendants as:
_doLimitQuery (line 290)

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

do a query which return results

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

Redefined in descendants as:
_quote (line 298)

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, 22 Mar 2012 22:15:16 +0100 by phpDocumentor 1.4.3