1
0
mirror of synced 2024-12-14 07:06:04 +03:00
This commit is contained in:
zYne 2007-06-11 15:40:31 +00:00
parent 43af7b69f2
commit 670a961a3b
2 changed files with 10 additions and 28 deletions

View File

@ -73,13 +73,10 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
private function __construct() private function __construct()
{ {
$this->_root = dirname(__FILE__); $this->_root = dirname(__FILE__);
$this->_null = new Doctrine_Null; $this->_null = new Doctrine_Null;
Doctrine_Record::initNullObject($this->_null);
Doctrine_Collection::initNullObject($this->_null);
Doctrine_Record_Iterator::initNullObject($this->_null); Doctrine_Record_Iterator::initNullObject($this->_null);
Doctrine_Validator::initNullObject($this->_null); Doctrine_Validator::initNullObject($this->_null);
Doctrine_Record_Filter::initNullObject($this->_null);
Doctrine_Object::initNullObject($this->_null); Doctrine_Object::initNullObject($this->_null);
} }
/** /**

View File

@ -31,17 +31,12 @@
* @since 1.0 * @since 1.0
* @version $Revision: 1298 $ * @version $Revision: 1298 $
*/ */
class Doctrine_Record_Filter class Doctrine_Record_Filter extends Doctrine_Object
{ {
/** /**
* @var Doctrine_Record $_record the record object this filter belongs to * @var Doctrine_Record $_record the record object this filter belongs to
*/ */
protected $_record; protected $_record;
/**
* @var Doctrine_Null $null a Doctrine_Null object used for extremely fast
* null value testing
*/
private static $null;
/** /**
* constructor * constructor
* *
@ -60,16 +55,6 @@ class Doctrine_Record_Filter
{ {
return $this->_record; return $this->_record;
} }
/**
* initNullObject
*
* @param Doctrine_Null $null
* @return void
*/
public static function initNullObject(Doctrine_Null $null)
{
self::$null = $null;
}
/** /**
* setDefaultValues * setDefaultValues
* sets the default values for records internal data * sets the default values for records internal data
@ -89,10 +74,10 @@ class Doctrine_Record_Filter
$default = $table->getDefaultValueOf($column); $default = $table->getDefaultValueOf($column);
if ($default === null) { if ($default === null) {
$default = self::$null; $default = self::$_null;
} }
if ($value === self::$null || $overwrite) { if ($value === self::$_null || $overwrite) {
$this->_record->rawSet($column, $default); $this->_record->rawSet($column, $default);
$modified[] = $column; $modified[] = $column;
$this->_record->state(Doctrine_Record::STATE_TDIRTY); $this->_record->state(Doctrine_Record::STATE_TDIRTY);
@ -133,12 +118,12 @@ class Doctrine_Record_Filter
$type = $this->_record->getTable()->getTypeOf($name); $type = $this->_record->getTable()->getTypeOf($name);
if ( ! isset($tmp[$name])) { if ( ! isset($tmp[$name])) {
$data[$name] = self::$null; $data[$name] = self::$_null;
} else { } else {
switch ($type) { switch ($type) {
case 'array': case 'array':
case 'object': case 'object':
if ($tmp[$name] !== self::$null) { if ($tmp[$name] !== self::$_null) {
if (is_string($tmp[$name])) { if (is_string($tmp[$name])) {
$value = unserialize($tmp[$name]); $value = unserialize($tmp[$name]);
@ -152,7 +137,7 @@ class Doctrine_Record_Filter
} }
break; break;
case 'gzip': case 'gzip':
if ($tmp[$name] !== self::$null) { if ($tmp[$name] !== self::$_null) {
$value = gzuncompress($tmp[$name]); $value = gzuncompress($tmp[$name]);
if ($value === false) { if ($value === false) {
@ -186,14 +171,14 @@ class Doctrine_Record_Filter
$this->_id = array(); $this->_id = array();
if (count($id) > 1) { if (count($id) > 1) {
foreach ($id as $name) { foreach ($id as $name) {
if ($this->_data[$name] === self::$null) { if ($this->_data[$name] === self::$_null) {
$this->_id[$name] = null; $this->_id[$name] = null;
} else { } else {
$this->_id[$name] = $this->_data[$name]; $this->_id[$name] = $this->_data[$name];
} }
} }
} else { } else {
if (isset($this->_data[$id]) && $this->_data[$id] !== self::$null) { if (isset($this->_data[$id]) && $this->_data[$id] !== self::$_null) {
$this->_id[$id] = $this->_data[$id]; $this->_id[$id] = $this->_data[$id];
} }
} }
@ -216,7 +201,7 @@ class Doctrine_Record_Filter
foreach ($array as $k => $v) { foreach ($array as $k => $v) {
$type = $this->_table->getTypeOf($v); $type = $this->_table->getTypeOf($v);
if ($this->_data[$v] === self::$null) { if ($this->_data[$v] === self::$_null) {
$a[$v] = null; $a[$v] = null;
continue; continue;
} }