BlueShoes Application Framework made with PHP http://www.blueshoes.org/


Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: C:/usr/local/lib/php/blueshoes-4.2/core/storage/oodb/Bs_OoDbForMySql.class.php
BlueShoes Application Framework - storage/oodb @status experimental

Bs_OoDbForMySql

Bs_Object
   |
  +-- Bs_OoDbBasics
     |
    +-- Bs_OoDb
       |
      +-- Bs_OoDbForMySql

**********************************************************************

 

public class Bs_OoDbForMySql extends Bs_OoDb

**********************************************************************
Imlementation of the abstract class Bs_OoDb in MySQL.

Authors
Version4.0.$Revision: 1.1.1.1 $
Copyrightblueshoes.org

 

Methods inherited from Bs_OoDb

bs_oodb, &softdelete, persist, &unpersist, _unpersistobject, &oquery, pizza, &_delete, getstoragescope, fetchobjectdata, queryfetch, deleteobjectdata, fetchcihchildren, fetchcihparents

Methods inherited from Bs_OoDbBasics

bs_oodbbasics, _setobject, &_getoodbproperty, _preparetopersistdata, _reassembleobjectmetadata, getid, setid, getscope, sethardscope, forcesave, &getpersisttag, _memorizeobjstored, _isobjalreadystored, _unmemorizeobjstored, _memorizeobjfetched, &_getobjalreadyfetched, _unmemorizeobjfetched, &_calcmd5fingerprint, &_flattenobjarray, &flattenobjarray, &_getstreamfields, &getfieldnames, _seterror_store, &geterror_persist, _flattenobjarray, _seterror_fetch, _seterror_delete, &geterror_unpersist, &geterror_delete, &errordump

Methods inherited from Bs_Object

isex, isexception, tostring, tohtml, persist, unpersist, bs_object, bbsetoutput, bbawake, bbisawake, bbxmsg, bbxfunctionstart, bbxfunctionend, bbxecho, bbxvar, bbxvardump, bbforcetrace, bbbufferstart, bbbufferget, bbbufferendflush, bbbufferendclean

Public Method Summary

void

Bs_OoDbForMySql([ string $dbObject ])

Constuctor.
bool

dropTable( $tblName)

Drop the db table (if it exists).
bool

createClassTable( $dbName, $tblName, &$ooDbProperty)

Create the db table.

Private Method Summary

void

deleteAllObjectRelation( $parentClass, $parentID, string $dbName, string $exclueVarNames)

Warning: documentation is missing.
void

deleteObjectRelation( $parentClass, $parentID, $chieldClass, $chieldID, string $dbName)

Warning: documentation is missing.
void

&deleteObjectData( $tblName, $objID, string $dbName)

To prevent deadlocks, always start deleting with the main clearInHouse-Table
integer

storeObjectData( &$lonelyList, $tblName, string $dbName)

Store the passed $lonelyList-data (=objdect data) in the table.Warning: documentation is missing.
void

storeClearInHouse( &$clearInHouseData, string $dbName)

$clearInHouseData[]['parentClass'] = $this->pObjName;Warning: documentation is missing.
array

&fetchCihParents( $tblName, $objID, string $reference, string $dbName)

NOTE catches exception 'No such table in db' and returns empty array.
array

&fetchCihChildren( $tblName, $objID, string $reference, string $dbName)

NOTE catches exception 'No such table in db' and returns empty array.
array

&fetchObjectData( $tblName, $sqlSomething, string $dbName)

void

&queryFetch( $completeQuery)

Get rec-array of any complete query
void

matchDbFields_Versus_OoDbProperty( $dbName, $tblName, &$ooDbProperty)

Match the object fields against the table fields of the $tblName in the database.
void

_assembleSqlQueryForClassTbl( $dbName, $tblName, &$ooDbProperty, string $createAddChange)

void

createClassTableFromName(string $class, $dbName)

If only the className is passed we will try to instanciate the object. If it's not in our
void

&getStorageScope()

Warning: documentation is missing.
void

startTransaction(string $transactionId)

Optional:Warning: documentation is missing.
void

commit(string $transactionId)

Warning: documentation is missing.
void

rollback(string $transactionId)

Warning: documentation is missing.
void

_createClearInHouse( $tblName, string $dbName)

Warning: documentation is missing.
void

_typeTrans( &$dbType, &$metaType)

Warning: documentation is missing.
void

_dbType2metaType( $dbType)

Warning: documentation is missing.
void

_metaType2dbType( $metaType)

Warning: documentation is missing.

Fields inherited from Bs_OoDbBasics

$pmetadata, $pdatahaschanged, $pobjputinstorage, $pobjfetchedfromstorage, $perrorstore, $pobjtopersist, $pobjname, $pdefaultscope, $pstorageautocreate, $pinfolist, $perrorfetch, $perrordelete

Private Field Summary

object [unknown]

$bsDb

Reference to the db object.

Private Constant Summary

BS_OODBFORMYSQL_VERSION >>4.0.$x$<< Warning: documentation is missing.
BS_OBJPERSISTERFORMYSQL_VERSION >>4.0.$x$<< Warning: documentation is missing.
BS_OODB_CLEAR_IN_HOUSE_TBL >>_oodb_cih<< Warning: documentation is missing.
BS_OODB_CLEAR_IN_HOUSE_EXTENTION >>_cih<< Warning: documentation is missing.

Included files Summary, Type: require_once

$class Warning: documentation is missing.

Public Method Details

Bs_OoDbForMySql

public void Bs_OoDbForMySql( [ string $dbObject ] )

  Constuctor.

Parameter
string $dbObject = >>NULL<<
Returns void


dropTable

public bool dropTable( $tblName )

  Drop the db table (if it exists).

Parameter
$tblName
Warning: documentation is missing.
Returns bool

true on success
@throw bs_exception on failure. It's not a failure if the table doesn't exist.


createClassTable

public bool createClassTable( $dbName, $tblName, &$ooDbProperty )

  Create the db table.

Parameter
$dbName
Warning: documentation is missing.
$tblName
Warning: documentation is missing.
&$ooDbProperty
Warning: documentation is missing.
Returns bool

true on success.
@throw bs_exception on failure.


Private Method Details

deleteAllObjectRelation

private void deleteAllObjectRelation( $parentClass, $parentID, string $dbName, string $exclueVarNames )

 

Warning: documentation is missing.

Parameter
$parentClass
Warning: documentation is missing.
$parentID
Warning: documentation is missing.
string $dbName
Warning: documentation is missing.
string $exclueVarNames
Warning: documentation is missing.
Returns void

Throws exception *

deleteObjectRelation

private void deleteObjectRelation( $parentClass, $parentID, $chieldClass, $chieldID, string $dbName )

 

Warning: documentation is missing.

Parameter
$parentClass
Warning: documentation is missing.
$parentID
Warning: documentation is missing.
$chieldClass
Warning: documentation is missing.
$chieldID
Warning: documentation is missing.
string $dbName
Warning: documentation is missing.
Returns void

Throws exception *

&deleteObjectData

private void &deleteObjectData( $tblName, $objID, string $dbName )

  To prevent deadlocks, always start deleting with the main clearInHouse-Table
Delete all entries in the clearInHouse-table and <className>_cih-tables thatpoint to $tblName with ID $objID AND scope=''

Parameter
$tblName
Warning: documentation is missing.
$objID
Warning: documentation is missing.
string $dbName
Warning: documentation is missing.
Returns void

Throws exception on fail.

storeObjectData

private integer storeObjectData( &$lonelyList, $tblName, string $dbName )

  Store the passed $lonelyList-data (=objdect data) in the table.
Special Case when ID>0:We always expect to have an 'ID' in the $lonelyList-dataIf the ID>0 we assume it's an UPDATE (not a INSERT) and we try to UPDATE with the ID as record key*BUT* if for some reason the record isn't present (Because deleted or we are using an other db)MySql will return TRUE, doing nothing! MySql REPLACE would work, but it also would destroy datathat we are not setting. Checking for affectedRows() dosn't solve the problem 100% because whenusing UPDATE, mySQL will not update columns where the new value is the same as the old value.So I had to programm a fallback:if ID>0 try an UPDATE and call affectedRows();if I still get 0 try an INSERT and catch the mySQL error BS_DB_ERROR_ALREADY_EXISTS.

Warning: documentation is missing.

Parameter
&$lonelyList
Warning: documentation is missing.
$tblName
Warning: documentation is missing.
string $dbName
Warning: documentation is missing.
Returns integer

An ID>0 on successfull insert.

Throws exception on errors

storeClearInHouse

private void storeClearInHouse( &$clearInHouseData, string $dbName )

  $clearInHouseData[]['parentClass'] = $this->pObjName;
$clearInHouseData[]['parentID'] = $_persistTag['ID'];$clearInHouseData[]['varName'] = $varName;$clearInHouseData[]['scope'] = $persister->getScope();$clearInHouseData[]['chieldClass'] = $persister->pObjName;$clearInHouseData[]['chieldID'] = $chieldObjID;$clearInHouseData[]['hashKey'] = $hashKey;$clearInHouseData[]['weakRef'] = $_ooDbProperty[$varName]['reference'];$clearInHouseData[]['readOnly'] =*

Warning: documentation is missing.

Parameter
&$clearInHouseData
Warning: documentation is missing.
string $dbName
Warning: documentation is missing.
Returns void


&fetchCihParents

private array &fetchCihParents( $tblName, $objID, string $reference, string $dbName )

  NOTE catches exception 'No such table in db' and returns empty array.

Parameter
$tblName
Warning: documentation is missing.
$objID
Warning: documentation is missing.
string $reference
Warning: documentation is missing.
string $dbName
Warning: documentation is missing.
Returns array

if no data found.

Throws exception

&fetchCihChildren

private array &fetchCihChildren( $tblName, $objID, string $reference, string $dbName )

  NOTE catches exception 'No such table in db' and returns empty array.

Parameter
$tblName
Warning: documentation is missing.
$objID
Warning: documentation is missing.
string $reference
Warning: documentation is missing.
string $dbName
Warning: documentation is missing.
Returns array

if no data found.

Throws exception

&fetchObjectData

private array &fetchObjectData( $tblName, $sqlSomething, string $dbName )

 

Parameter
$tblName
Warning: documentation is missing.
$sqlSomething
Warning: documentation is missing.
string $dbName
Warning: documentation is missing.
Returns array

with data if OK / NULL if no data or no table found.

Throws exception

&queryFetch

private void &queryFetch( $completeQuery )

  Get rec-array of any complete query

Parameter
$completeQuery
Warning: documentation is missing.
Returns void


matchDbFields_Versus_OoDbProperty

private void matchDbFields_Versus_OoDbProperty( $dbName, $tblName, &$ooDbProperty )

  Match the object fields against the table fields of the $tblName in the database.
Return a hash of following format:$dbMatch[<filedName>] = array( 'status' => ['missing'|'mismatch'|'ok'],'metaType' => '','newDbType' => '','currentDbType' => '',)

Parameter
$dbName
Warning: documentation is missing.
$tblName
Warning: documentation is missing.
&$ooDbProperty
Warning: documentation is missing.
Returns void


_assembleSqlQueryForClassTbl

private void _assembleSqlQueryForClassTbl( $dbName, $tblName, &$ooDbProperty, string $createAddChange )

 

Parameter
$dbName
Warning: documentation is missing.
$tblName
Warning: documentation is missing.
&$ooDbProperty
Warning: documentation is missing.
string $createAddChange
Warning: documentation is missing.
Returns void


createClassTableFromName

private void createClassTableFromName( string $class, $dbName )

  If only the className is passed we will try to instanciate the object. If it's not in our
scope -> ExceptionIf you pass a full path <class>.class.php file, we will first try to include the file andthe instanciate the object.

Parameter
string $class
. Is either the className or the full path AND file name of a <class>.class.php
$dbName
Warning: documentation is missing.
Returns void


&getStorageScope

private void &getStorageScope( )

 

Warning: documentation is missing.

Returns void


startTransaction

private void startTransaction( string $transactionId )

  Optional:
Overload transaction functions if underlying storage provides them.

Warning: documentation is missing.

Parameter
string $transactionId
Warning: documentation is missing.
Returns void


commit

private void commit( string $transactionId )

 

Warning: documentation is missing.

Parameter
string $transactionId
Warning: documentation is missing.
Returns void


rollback

private void rollback( string $transactionId )

 

Warning: documentation is missing.

Parameter
string $transactionId
Warning: documentation is missing.
Returns void


_createClearInHouse

private void _createClearInHouse( $tblName, string $dbName )

 

Warning: documentation is missing.

Parameter
$tblName
Warning: documentation is missing.
string $dbName
Warning: documentation is missing.
Returns void


_typeTrans

private void _typeTrans( &$dbType, &$metaType )

 

Warning: documentation is missing.

Parameter
&$dbType
Warning: documentation is missing.
&$metaType
Warning: documentation is missing.
Returns void


_dbType2metaType

private void _dbType2metaType( $dbType )

 

Warning: documentation is missing.

Parameter
$dbType
Warning: documentation is missing.
Returns void


_metaType2dbType

private void _metaType2dbType( $metaType )

 

Warning: documentation is missing.

Parameter
$metaType
Warning: documentation is missing.
Returns void


Private Field Details

$bsDb

private object [unknown] $bsDb

>><<

Reference to the db object.


Private Constant Details

BS_OODBFORMYSQL_VERSION

define( BS_OODBFORMYSQL_VERSION, >>4.0.$x$<< )
Case: default: case sensitive



BS_OBJPERSISTERFORMYSQL_VERSION

define( BS_OBJPERSISTERFORMYSQL_VERSION, >>4.0.$x$<< )
Case: default: case sensitive



BS_OODB_CLEAR_IN_HOUSE_TBL

define( BS_OODB_CLEAR_IN_HOUSE_TBL, >>_oodb_cih<< )
Case: default: case sensitive



BS_OODB_CLEAR_IN_HOUSE_EXTENTION

define( BS_OODB_CLEAR_IN_HOUSE_EXTENTION, >>_cih<< )
Case: default: case sensitive



Included Files, Type: require_once

$class

require_once( $class )




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta