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

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

  • access: public
mixed $lastQuery (line 65)

last executed query

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

The last error message if any

  • access: public
array $profile (line 48)

profile properties used by the connector

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

the internal connection.

  • access: protected
jDbSchema $_schema = null (line 368)
  • since: 1.2
  • access: protected
jDbTools $_tools = null (line 346)
  • since: 1.2
  • access: protected
Methods
Constructor __construct (line 82)

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

Redefined in descendants as:
beginTransaction (line 229)

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

validate all queries and close a transaction

  • abstract:
  • access: public
void commit ()

Redefined in descendants as:
encloseFieldName (line 186)
void encloseFieldName ( $fieldName)
  • $fieldName
encloseName (line 178)

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

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

Redefined in descendants as:
exec (line 135)

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 272)
  • 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 212)

Check if the current connection has a table prefix set

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

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

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

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

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

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

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

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

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

cancel all queries of a transaction and close the transaction

  • abstract:
  • access: public
void rollback ()

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

sets the autocommit state

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

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

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

do a disconnection

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

  • abstract:
  • access: protected
void _disconnect ()

Redefined in descendants as:
_doExec (line 324)

do a query which return nothing

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

Redefined in descendants as:
_doLimitQuery (line 330)

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

do a query which return results

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

Redefined in descendants as:
_quote (line 338)

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, 19 Sep 2011 14:12:27 +0200 by phpDocumentor 1.4.3