Class Persistence

Description

Public interface for the phpersistence layer.

  • author: Michael Haussmann

Located in /Persistence.class.php (line 29)


	
			
Method Summary
Persistence Persistence ()
bool delete ($object &$object, [bool $deleteInstance = true])
result execute (string $sql)
array findByExample ($object $object)
array findBySQL (string $sqlQuery, string $className)
void findOneByExample (mixed $object)
array getAll (mixed $className)
objects getById (string $className, mixed $primaryKey)
void getSelectFields (mixed $className)
void load ($object &$object, mixed $primaryKey)
mixed save ($object &$object)
void saveOrUpdate ($object &$object)
bool update ($object &$object, [mixed $isValidating = false])
Methods
Constructor Persistence (line 45)
Persistence Persistence ()
delete (line 193)

Deletes an object.

The second optional boolean parameter may be set to false if the instance should not be deleted from memory. By default, it is set to null.

  • return: true on success, false on error
bool delete ($object &$object, [bool $deleteInstance = true])
  • $object $object: object to save
  • bool $deleteInstance: : set to false if you want the instance of the object "survive" this deletion.
execute (line 221)

Executes the given SQL query. Simple implementation (TODO :has to be worked over)

result execute (string $sql)
  • string $sql: query
findByExample (line 114)

Returns an array of objects as found by example.

  • return: an array of objects
array findByExample ($object $object)
  • $object $object: an example object
findBySQL (line 137)

Returns an array of objects of type $className, as found with the given $sqlQuery.

  • return: an array of objects
array findBySQL (string $sqlQuery, string $className)
  • string $sqlQuery
  • string $className
findOneByExample (line 125)
void findOneByExample (mixed $object)
getAll (line 80)

Returns all objects of a given type. Simple implementation ignoring inheritence.

  • return: of objects of type $className or an empty array
array getAll (mixed $className)
getById (line 105)

Gets an object as found with the given primary Key.

If no object is found, null is returned. If multiple objects are found (what should not occur if the param is a real primary key), only the first object is returned.

  • return: of type $className
objects getById (string $className, mixed $primaryKey)
  • string $className
  • mixed $primaryKey
getConfiguration (line 70)
  • return: configuration
  • access: protected
PersistenceConfiguration getConfiguration (void 0)
  • void 0
getSelectFields (line 87)
  • access: protected
void getSelectFields (mixed $className)
load (line 211)

Loads an object, as found with the given primary Key, into the given instance.

If no object is found, null is returned. If multiple objects are found (what should not occur if the param is a real primary key), only the first object is returned.

void load ($object &$object, mixed $primaryKey)
  • mixed $primaryKey
  • $object &$object: object instance
save (line 166)

Saves an object

  • return: : new primary key if the database created one, or false on error
mixed save ($object &$object)
  • $object $object: object to save
saveOrUpdate (line 151)

Saves or Updates an object according to it's state :

- if it has a valid primary key, it has already been saved once, so update - if not, object is saved

If possible, it is better to use the save() or update() explicitely, and not to rely on this method.

void saveOrUpdate ($object &$object)
  • $object &$object: to save or update
update (line 177)

Updates an object

  • return: true on success, false on error
bool update ($object &$object, [mixed $isValidating = false])
  • $object $object: object to save

Documentation generated on Wed, 5 May 2004 20:19:59 +0200 by phpDocumentor 1.3.0RC3