Subversion Repositories PHPX

Compare Revisions

Last modification

Ignore whitespace Rev 55 → Rev 62

/trunk/Model.php
8,6 → 8,7
* Provides simple mapping of a model object to records of
* a table of a relational database.
*
* @property Db\Table $persistentTable
* @author Thomas Lahn
*/
abstract class Model extends \PointedEars\PHPX\AbstractModel
126,14 → 127,22
* Finds the record for the model object in the table, fills
* the object with missing data, and returns the result.
*
* @param mixed $id = null
* The ID of the object to find. If <code>null</code> (default),
* the object is search for by its current ID.
* @see Table::find(Model)
* @return Model|null
* This object filled with missing data, or <code>null</code>
* if there is no data for this object
*/
public function find ()
public function find ($id = null)
{
$class = \get_class($this);
if ($id !== null)
{
$this->{$class::$_persistentId} = $id;
}
 
$result = $this->persistentTable->find($this->{$class::$_persistentId});
if ($result)
{
151,6 → 160,8
* in the database. The default is to save the values
* of all persistent properties.
* @return boolean
* The return value of
* <code>$this->persistentTable->updateOrInsert()</code>.
* @see Model::getPropertyArray()
* @see Table::updateOrInsert()
*/