blueshoes php application framework and cms            core_storage
[ class tree: core_storage ] [ index: core_storage ] [ all elements ]

Class: Bs_OoDbForMySql

Source Location: /core/storage/oodb/Bs_OoDbForMySql.class.php

Class Overview

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

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


Author(s):

Version:

  • 4.0.$Revision: 1.2 $

Copyright:

  • blueshoes.org

Variables

Methods


Inherited Variables

Inherited Methods

Class: Bs_OoDb

Bs_OoDb::Bs_OoDb()
Constuctor.
Bs_OoDb::commit()
Bs_OoDb::deleteAllObjectRelation()
Bs_OoDb::deleteObjectData()
Bs_OoDb::deleteObjectRelation()
Bs_OoDb::fetchCihChildren()
Bs_OoDb::fetchCihParents()
Bs_OoDb::fetchObjectData()
Bs_OoDb::getStorageScope()
Bs_OoDb::oQuery()
It's sufficent that the query only selects the ID $className and result of query must match! $scope and scope of query must match! * --sb OPTIMISATION : Gather all the records at once, instanciate 1 object and duplicate it times rec-number.
Bs_OoDb::persist()
Persist a object 1) Check if the object passed ($obj) has already been stored. If so, return ID.
Bs_OoDb::queryFetch()
Bs_OoDb::rollback()
Bs_OoDb::softDelete()
Only delete the object (and chield-objects) if no strong references point to it.
Bs_OoDb::startTransaction()
Optional: Overload transaction functions if underlying storage provides them.
Bs_OoDb::storeClearInHouse()
Bs_OoDb::storeObjectData()
Bs_OoDb::unpersist()
Unpersist a object - Dramatic dynamic :-) 1) IF className is passed, instanceiate an object(suppressing any missing parameter warnings) ELSE use passed object assuming it's the right class (read on to see what is the *right* class).

Class: Bs_OoDbBasics

Bs_OoDbBasics::Bs_OoDbBasics()
Constructor During the process of storing '$this' is cloned (copied), reset and reused.
Bs_OoDbBasics::errorDump()
Bs_OoDbBasics::flattenObjArray()
Wrapper for function _flattenObjArray()
Bs_OoDbBasics::forceSave()
If 'forceSave' is set to TRUE the "md5 autodetect modification" will not be used and the data will always be stored.
Bs_OoDbBasics::getError_Delete()
Bs_OoDbBasics::getError_Persist()
Bs_OoDbBasics::getError_Unpersist()
Bs_OoDbBasics::getFieldNames()
I sometimes need all varNames that will have a filed in the underlying storage
Bs_OoDbBasics::getID()
Get the objects sorage ID.
Bs_OoDbBasics::getPersistTag()
Status info is set in the $_persistTag -hash. For exsample the ID of the object when it's fetched from the storage. The $_persistTag is dependent on the scope. (See header info: Scope) Thus the ID may differ from one scope to the other.
Bs_OoDbBasics::getScope()
(See header info: Scope) Get the scope; the area to store the data.
Bs_OoDbBasics::setHardScope()
(See header info: Scope) Set a 'strong'-scope. That is: the passed object will be stored with the given scope.
Bs_OoDbBasics::setID()
Set the objects sorage ID.
Bs_OoDbBasics::_getStreamFields()
I sometimes need all the streamNames from the PersistProperty
Bs_OoDbBasics::_setError_Delete()
Bs_OoDbBasics::_setError_Fetch()
Bs_OoDbBasics::_setError_Store()

Class: Bs_Object

Bs_Object::Bs_Object()
Bs_Object::getErrors()
Basic error handling: Get *all* errors as string array from the global Bs_Error-error stack.
Bs_Object::getLastError()
Basic error handling: Get last error string from the global Bs_Error-error stack.
Bs_Object::getLastErrors()
Basic error handling: Get last errors string array from the global Bs_Error-error stack sinc last call of getLastErrors().
Bs_Object::persist()
Persists this object by serializing it and saving it to a file with unique name.
Bs_Object::setError()
Basic error handling: Push an error string on the global Bs_Error-error stack.
Bs_Object::toHtml()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::toString()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::unpersist()
Fetches an object that was persisted with persist()

Class Details

[line 37]
*********************************************************************** Imlementation of the abstract class Bs_OoDb in MySQL.



Tags:

access:  public
version:  4.0.$Revision: 1.2 $
status:  deprecated USE Bs_SimpleObjPersister
copyright:  blueshoes.org
author:  Sam Blum <at blueshoes dot org>


[ Top ]


Class Variables

$bsDb =

[line 42]

Reference to the db object.


Type:   object


[ Top ]



Class Methods


constructor Bs_OoDbForMySql [line 50]

Bs_OoDbForMySql Bs_OoDbForMySql( [object $dbObject = NULL], object &$obj, array $varSettings)

Constuctor.



Parameters:

object   &$obj  
array   $varSettings   (pass it by ref)
object   $dbObject   you can give your own db object here, otherwise the global main connection will be used. (pass it by ref if possible)

[ Top ]

method commit [line 408]

void commit( [mixed $transactionId = ''])



Overrides Bs_OoDb::commit() (parent method not documented)

[ Top ]

method createClassTable [line 584]

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

Create the db table.



Tags:

return:  true on success.
throws:  bs_exception on failure.
access:  public


[ Top ]

method createClassTableFromName [line 662]

void createClassTableFromName( $className $class, mixed $dbName)

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



Parameters:

$className   $class   string. Is either the className or the full path AND file name of a <class>.class.php

[ Top ]

method deleteAllObjectRelation [line 63]

TURE deleteAllObjectRelation( mixed $parentClass, mixed $parentID, [mixed $dbName = ''], [mixed $exclueVarNames = ''])



Tags:

return:  or exception
throws:  exception


Overrides Bs_OoDb::deleteAllObjectRelation() (parent method not documented)

[ Top ]

method deleteObjectData [line 131]

TRUE &deleteObjectData( mixed $tblName, mixed $objID, [mixed $dbName = ''])

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

Delete all entries in the clearInHouse-table and <className>_cih-tables that point to $tblName with ID $objID AND scope=''




Tags:

return:  on success
throws:  exception on fail.


Overrides Bs_OoDb::deleteObjectData() (parent method not documented)

[ Top ]

method deleteObjectRelation [line 101]

TURE deleteObjectRelation( mixed $parentClass, mixed $parentID, mixed $chieldClass, mixed $chieldID, [mixed $dbName = ''])



Tags:

return:  or exception
throws:  exception


Overrides Bs_OoDb::deleteObjectRelation() (parent method not documented)

[ Top ]

method dropTable [line 426]

bool dropTable( mixed $tblName)

Drop the db table (if it exists).



Tags:

return:  true on success
throws:  bs_exception on failure. It's not a failure if the table doesn't exist.
access:  public


[ Top ]

method fetchCihChildren [line 358]

empty &fetchCihChildren( mixed $tblName, mixed $objID, [mixed $reference = ''], [mixed $dbName = ''])

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



Tags:

return:  array if no data found.
throws:  exception


Overrides Bs_OoDb::fetchCihChildren() (parent method not documented)

[ Top ]

method fetchCihParents [line 340]

empty &fetchCihParents( mixed $tblName, mixed $objID, [mixed $reference = ''], [mixed $dbName = ''])

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



Tags:

return:  array if no data found.
throws:  exception


Overrides Bs_OoDb::fetchCihParents() (parent method not documented)

[ Top ]

method fetchObjectData [line 375]

array &fetchObjectData( mixed $tblName, mixed $sqlSomething, [mixed $dbName = ''])



Tags:

return:  with data if OK / NULL if no data or no table found.
throws:  exception


Overrides Bs_OoDb::fetchObjectData() (parent method not documented)

[ Top ]

method getStorageScope [line 717]

void &getStorageScope( )



Overrides Bs_OoDb::getStorageScope() (parent method not documented)

[ Top ]

method matchDbFields_Versus_OoDbProperty [line 498]

hash matchDbFields_Versus_OoDbProperty( mixed $dbName, mixed $tblName, mixed &$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' => '', )




Tags:

return:  on success. (See above)
throws:  bs_exception on failure.


[ Top ]

method queryFetch [line 398]

void &queryFetch( mixed $completeQuery)

Get rec-array of any complete query



Overrides Bs_OoDb::queryFetch() (parent method not documented)

[ Top ]

method rollback [line 412]

void rollback( [mixed $transactionId = ''])



Overrides Bs_OoDb::rollback() (parent method not documented)

[ Top ]

method startTransaction [line 404]

void startTransaction( [mixed $transactionId = ''])



Overrides Bs_OoDb::startTransaction() (Optional: Overload transaction functions if underlying storage provides them.)

[ Top ]

method storeClearInHouse [line 279]

void storeClearInHouse( mixed &$clearInHouseData, [mixed $dbName = ''])



Overrides Bs_OoDb::storeClearInHouse() (parent method not documented)

[ Top ]

method storeObjectData [line 196]

integer storeObjectData( mixed &$lonelyList, mixed $tblName, [mixed $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-data If 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 data that we are not setting. Checking for affectedRows() dosn't solve the problem 100% because when using 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.




Tags:

return:  An ID>0 on successfull insert.
throws:  exception on errors


Overrides Bs_OoDb::storeObjectData() (parent method not documented)

[ Top ]

method _assembleSqlQueryForClassTbl [line 541]

void _assembleSqlQueryForClassTbl( mixed $dbName, mixed $tblName, mixed &$ooDbProperty, [mixed $createAddChange = 'create'])



[ Top ]

method _createClearInHouse [line 436]

void _createClearInHouse( mixed $tblName, [mixed $dbName = ''])



[ Top ]

method _dbType2metaType [line 475]

void _dbType2metaType( mixed $dbType)



[ Top ]

method _metaType2dbType [line 481]

void _metaType2dbType( mixed $metaType)



[ Top ]

method _typeTrans [line 462]

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



[ Top ]


Documentation generated on Mon, 29 Dec 2003 21:12:28 +0100 by phpDocumentor 1.2.3