Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
DbObj Class Reference
+ Inheritance diagram for DbObj:
+ Collaboration diagram for DbObj:

Public Member Functions

 __construct ($dbaccess= '', $id= '', $res= '', $dbid=0)
 
 Select ($id)
 
 getValues ()
 
 affectColumn ($fields, $reset=true)
 
 affect ($array, $more=false, $reset=true)
 
 isAffected ()
 
 Complete ()
 
 preInsert ()
 
 postInsert ()
 
 preUpdate ()
 
 postUpdate ()
 
 preDelete ()
 
 postDelete ()
 
 preSelect ($id)
 
 postSelect ($id)
 
 Add ($nopost=false, $nopre=false)
 
 modify ($nopost=false, $sfields="", $nopre=false)
 
 delete ($nopost=false)
 
 Adds (&$tcopy, $nopost=false)
 
 lw ($prop)
 
 CloseConnect ()
 
 Create ($nopost=false)
 
 postInit ()
 
 init_dbid ()
 
 exec_query ($sql, $lvl=0, $prepare=false)
 
 numrows ()
 
 fetch_array ($c, $type=PGSQL_ASSOC)
 
 update ()
 
 setError ($moreerr= '')
 
 autoUpdate ()
 
 savePoint ($point)
 
 lockPoint ($exclusiveLock, $exclusiveLockPrefix= '')
 
 setMasterLock ($useLock)
 
 rollbackPoint ($point)
 
 commitPoint ($point)
 

Data Fields

 $dbid = - 1
 
 $dbaccess = ''
 
 $fields
 
 $dbtable = ''
 
 $id_fields
 
 $criterias = array()
 
 $sup_fields = array()
 
 $sup_where = array()
 
 $sup_tables = array()
 
 $fulltextfields = array()
 
 $order_by = ""
 
 $isset = false
 
 $msg_err = ''
 
 $err_code = ''
 
 $res = ''
 
 $debug = false
 
 $sqlcreate
 
 $sqlinit
 
 $log
 

Static Public Attributes

static $savepoint = array()
 
static $lockpoint = array()
 
static $sqlStrict = null
 

Protected Member Functions

 tryCreate ()
 

Detailed Description

This class is a generic DB Class that can be used to create objects based on the description of a DB Table. More Complex Objects will inherit from this basic Class.

Definition at line 28 of file Class.DbObj.php.

Constructor & Destructor Documentation

__construct (   $dbaccess = '',
  $id = '',
  $res = '',
  $dbid = 0 
)

Database Object constructor

Parameters
string$dbaccessdatabase specification
int | array$ididentifier of the object
array$resarray of result issue to QueryDb QueryDb::Query()
resource$dbidthe database connection resource
Returns
bool false if error occured

Definition at line 113 of file Class.DbObj.php.

+ Here is the call graph for this function:

Member Function Documentation

Add (   $nopost = false,
  $nopre = false 
)

Add the object to the database

Parameters
bool$nopostPostInsert method not apply if true
bool$noprePreInsert method not apply if true
Returns
string error message, if no error empty string
See Also
PreInsert()
PostInsert()

Definition at line 413 of file Class.DbObj.php.

+ Here is the call graph for this function:

Adds ( $tcopy,
  $nopost = false 
)

Add several objects to the database no post neither preInsert are called

Parameters
bool$nopostPostInsert method not apply if true
Returns
string error message, if no error empty string
See Also
PreInsert()
PostInsert()

Definition at line 536 of file Class.DbObj.php.

affect (   $array,
  $more = false,
  $reset = true 
)

affect object with a set of values

Parameters
array$arrayindexed array of values , index if the column attribute

Definition at line 278 of file Class.DbObj.php.

+ Here is the call graph for this function:

affectColumn (   $fields,
  $reset = true 
)

affect object specific column values from this item use only when object is already affected

Parameters
array$fieldssql field to affect
Returns
bool true if OK false else

Definition at line 245 of file Class.DbObj.php.

+ Here is the call graph for this function:

autoUpdate ( )
Deprecated:
not used now
Returns
string

Definition at line 832 of file Class.DbObj.php.

+ Here is the call graph for this function:

CloseConnect ( )

Definition at line 567 of file Class.DbObj.php.

commitPoint (   $point)

commit transaction save point

Parameters
string$point
Returns
string error message

Definition at line 1061 of file Class.DbObj.php.

+ Here is the call graph for this function:

Complete ( )
See Also
affect

Definition at line 303 of file Class.DbObj.php.

Create (   $nopost = false)

Definition at line 573 of file Class.DbObj.php.

+ Here is the call graph for this function:

delete (   $nopost = false)

Delete the object on the database

Parameters
bool$nopostPostUpdate() and method not apply if true
Returns
string error message, if no error empty string

Definition at line 501 of file Class.DbObj.php.

+ Here is the call graph for this function:

exec_query (   $sql,
  $lvl = 0,
  $prepare = false 
)

Send a request to database

Parameters
string$sqlthe query
int$lvllevel set to 0 (internal purpose only)
bool$prepareset to true to use pg_prepare, restrict to use single query
Exceptions
Dcp\Db\Exceptionif query fail
Returns
string error message if not strict mode

Definition at line 698 of file Class.DbObj.php.

+ Here is the call graph for this function:

fetch_array (   $c,
  $type = PGSQL_ASSOC 
)

Definition at line 804 of file Class.DbObj.php.

getValues ( )

get all values in indexed array

Returns
array

Definition at line 231 of file Class.DbObj.php.

init_dbid ( )

Definition at line 606 of file Class.DbObj.php.

+ Here is the call graph for this function:

isAffected ( )

verify that the object exists in database test if object has fields id set if true values of the object has been set @æpi test if object if affected

See Also
affect
Returns
bool

Definition at line 296 of file Class.DbObj.php.

lockPoint (   $exclusiveLock,
  $exclusiveLockPrefix = '' 
)

Set a database transaction advisory lock

  • A transaction advisory lock can only be used within an existing transaction. So, a transaction must have been explicitly opened by a call to DbObj::savePoint() before using DbObj::lockPoint().
  • The lock is automatically released when the transaction is commited or rolled back.
Parameters
int$exclusiveLockLock's identifier as a signed integer in the int32 range (i.e. in the range [-2147483648, 2147483647]).
string$exclusiveLockPrefixLock's prefix string limited up to 4 bytes.
See Also
Dbobj::savePoint()
Exceptions
\Dcp\ExceptionDB0010, DB0011, and DB0012
Returns
string error message

Definition at line 960 of file Class.DbObj.php.

+ Here is the call graph for this function:

lw (   $prop)

Definition at line 562 of file Class.DbObj.php.

modify (   $nopost = false,
  $sfields = "",
  $nopre = false 
)

Save the object to the database

Parameters
bool$nopostPostUpdate() and method not apply if true
string$sfieldsonly this column will ne updated if empty all fields
bool$noprePreUpdate() method not apply if true
Returns
string error message, if no error empty string
See Also
PreUpdate()
PostUpdate()

Definition at line 449 of file Class.DbObj.php.

+ Here is the call graph for this function:

numrows ( )

number of return rows after exec_query

See Also
exec_query
Returns
int

Definition at line 795 of file Class.DbObj.php.

postDelete ( )

Method use after delete method

See Also
delete
Returns
string

Definition at line 376 of file Class.DbObj.php.

postInit ( )

Definition at line 602 of file Class.DbObj.php.

postInsert ( )

Method use after Add method This method should be replaced by the Child Class

Returns
string error message, if no error empty string, if message error not empty the Add method is not completed
See Also
Add()

Definition at line 328 of file Class.DbObj.php.

postSelect (   $id)

Method use after select method

Parameters
mixed$idthe id use by select
See Also
select
Returns
string

Definition at line 399 of file Class.DbObj.php.

postUpdate ( )

Method use after Modify method This method should be replaced by the Child Class

Returns
string error message, if no error empty string, if message error not empty the Modify method is not completed
See Also
Modify()

Definition at line 354 of file Class.DbObj.php.

preDelete ( )

if return error message, deletion is aborded

See Also
delete
Returns
string

Definition at line 365 of file Class.DbObj.php.

preInsert ( )

Method use before Add method This method should be replaced by the Child Class if return error message, modify is aborded

Returns
string error message, if no error empty string
See Also
Add()

Definition at line 315 of file Class.DbObj.php.

preSelect (   $id)

Method use before select method

Parameters
mixed$idthe id use by select
See Also
select
Returns
string

Definition at line 388 of file Class.DbObj.php.

preUpdate ( )

Method use before Modify method This method should be replaced by the Child Class if return error message, modify is aborded

Returns
string error message, if no error empty string
See Also
Modify()

Definition at line 341 of file Class.DbObj.php.

rollbackPoint (   $point)

revert to transaction save point

Parameters
string$pointrevert point
Returns
string error message

Definition at line 1031 of file Class.DbObj.php.

+ Here is the call graph for this function:

savePoint (   $point)

set a database transaction save point

Parameters
string$pointpoint identifier
Exceptions
\Dcp\Exception
Returns
string error message

Definition at line 913 of file Class.DbObj.php.

+ Here is the call graph for this function:

Select (   $id)

Select object from its fields if fields has more then one variable, need to use an array

Parameters
int | array$id
Returns
bool|string

Definition at line 161 of file Class.DbObj.php.

+ Here is the call graph for this function:

setError (   $moreerr = '')

Definition at line 817 of file Class.DbObj.php.

+ Here is the call graph for this function:

setMasterLock (   $useLock)

set a database master lock the lock is free when explicit call with false parameter. When a master lock is set,

Parameters
bool$useLockset lock (true) or unlock (false)
See Also
Dbobj::lockPoint()
Returns
string error message

Definition at line 1007 of file Class.DbObj.php.

+ Here is the call graph for this function:

tryCreate ( )
protected

Definition at line 618 of file Class.DbObj.php.

+ Here is the call graph for this function:

update ( )

Definition at line 810 of file Class.DbObj.php.

+ Here is the call graph for this function:

Field Documentation

$criterias = array()

Definition at line 55 of file Class.DbObj.php.

$dbaccess = ''

Definition at line 39 of file Class.DbObj.php.

$dbid = - 1

Definition at line 34 of file Class.DbObj.php.

$dbtable = ''

Definition at line 51 of file Class.DbObj.php.

$debug = false

Definition at line 94 of file Class.DbObj.php.

$err_code = ''

Definition at line 86 of file Class.DbObj.php.

$fields
Initial value:
= array(
'*'
)

Definition at line 44 of file Class.DbObj.php.

$fulltextfields = array()

Definition at line 63 of file Class.DbObj.php.

$id_fields

Definition at line 53 of file Class.DbObj.php.

$isset = false

Definition at line 74 of file Class.DbObj.php.

$lockpoint = array()
static

Definition at line 76 of file Class.DbObj.php.

$log

Definition at line 100 of file Class.DbObj.php.

$msg_err = ''

Definition at line 82 of file Class.DbObj.php.

$order_by = ""

Definition at line 68 of file Class.DbObj.php.

$res = ''

Definition at line 90 of file Class.DbObj.php.

$savepoint = array()
static

Definition at line 75 of file Class.DbObj.php.

$sqlcreate

Definition at line 95 of file Class.DbObj.php.

$sqlinit

Definition at line 96 of file Class.DbObj.php.

$sqlStrict = null
static

Definition at line 78 of file Class.DbObj.php.

$sup_fields = array()

Definition at line 60 of file Class.DbObj.php.

$sup_tables = array()

Definition at line 62 of file Class.DbObj.php.

$sup_where = array()

Definition at line 61 of file Class.DbObj.php.


The documentation for this class was generated from the following file:
← centre documentaire © anakeen