Subversion Repositories PHPX

Compare Revisions

Last modification

Ignore whitespace Rev 54 → Rev 55

/trunk/Model.php
27,7 → 27,7
*
* @type string|array[string]
*/
protected $_persistentId = 'id';
protected static $_persistentId = 'id';
 
/**
* The names of the properties that should be used in database
43,7 → 43,7
*
* @type array
*/
protected $_persistentProperties = array();
protected static $_persistentProperties = array();
 
/**
* Creates a new model object
105,7 → 105,8
 
if ($propertyNames === null)
{
$propertyNames = $this->_persistentProperties;
$class = \get_class($this);
$propertyNames = $class::$_persistentProperties;
}
 
foreach ($propertyNames as $propertyName => $columnName)
133,7 → 134,7
public function find ()
{
$class = \get_class($this);
$result = $this->persistentTable->find($this->{$this->_persistentId});
$result = $this->persistentTable->find($this->{$class::$_persistentId});
if ($result)
{
return $this->map($result);
156,7 → 157,8
public function save (array $propertyNames = null)
{
$table = $this->persistentTable;
$idPropertyName = $this->_persistentId;
$class = \get_class($this);
$idPropertyName = $class::$_persistentId;
 
$result = $table->updateOrInsert(
$this->getPropertyArray($propertyNames),
187,7 → 189,8
public function insert (array $propertyNames = null)
{
$table = $this->persistentTable;
$idPropertyName = $this->_persistentId;
$class = \get_class($this);
$idPropertyName = $class::$_persistentId;
 
$result = $table->insert($this->getPropertyArray($propertyNames));
 
207,6 → 210,7
*/
public function delete ()
{
return $this->persistentTable->delete($this->{$this->_persistentId});
$class = \get_class($this);
return $this->persistentTable->delete($this->{$class::$_persistentId});
}
}