1
0
mirror of synced 2024-12-14 15:16:04 +03:00
This commit is contained in:
zYne 2007-05-16 22:28:32 +00:00
parent 33bb25ac20
commit 1b3e981737
2 changed files with 41 additions and 0 deletions

View File

@ -79,6 +79,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
Doctrine_Collection::initNullObject($this->null);
Doctrine_Record_Iterator::initNullObject($this->null);
Doctrine_Validator::initNullObject($this->null);
Doctrine_Record_Filter::initNullOjbect($this->null);
}
/**
* @return Doctrine_Null

View File

@ -55,6 +55,46 @@ class Doctrine_Record_Filter
{
return $this->_record;
}
/**
* initNullObject
*
* @param Doctrine_Null $null
* @return void
*/
public static function initNullObject(Doctrine_Null $null)
{
self::$null = $null;
}
/**
* setDefaultValues
* sets the default values for records internal data
*
* @param boolean $overwrite whether or not to overwrite the already set values
* @return boolean
*/
public function assignDefaultValues($data, $overwrite = false)
{
$table = $this->_record->getTable();
if ( ! $table->hasDefaultValues()) {
return false;
}
$modified = array();
foreach ($data as $column => $value) {
$default = $table->getDefaultValueOf($column);
if ($default === null) {
$default = self::$null;
}
if ($value === self::$null || $overwrite) {
$this->_record->rawSet($column, $default);
$modified[] = $column;
$this->_record->state(Doctrine_Record::STATE_TDIRTY);
}
}
$this->_record->setModified($modified);
}
/**
* cleanData
* this method does several things to records internal data