From 21cde0e7b9f67dbb1dc56753c41c1d1e33ac4352 Mon Sep 17 00:00:00 2001 From: chtito Date: Mon, 6 Nov 2006 18:34:10 +0000 Subject: [PATCH] new fix to #146 --- lib/Doctrine/Record.php | 6 +++--- lib/Doctrine/Table.php | 16 +--------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index 1e3578370..e13f1841f 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -126,13 +126,13 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite * open connections * @throws Doctrine_Record_Exception if the cleanData operation fails somehow */ - public function __construct($table = null) { + public function __construct($table = null, $isNewEntry = false) { if(isset($table) && $table instanceof Doctrine_Table) { $this->_table = $table; - $exists = ( ! $this->_table->isNewEntry()); + $exists = !$isNewEntry; } else { $this->_table = Doctrine_Manager::getInstance()->getCurrentConnection()->getTable(get_class($this)); - $exists = false; + $exists = false; } // Check if the current connection has the records table in its registry diff --git a/lib/Doctrine/Table.php b/lib/Doctrine/Table.php index c3635d44c..723dd294a 100644 --- a/lib/Doctrine/Table.php +++ b/lib/Doctrine/Table.php @@ -31,10 +31,6 @@ * @version 1.0 alpha */ class Doctrine_Table extends Doctrine_Configurable implements Countable { - /** - * @var boolean $isNewEntry whether ot not this table created a new record or not, used only internally - */ - private $isNewEntry = false; /** * @var array $data temporary data which is then loaded into Doctrine_Record::$data */ @@ -771,9 +767,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { */ public function create(array $array = array()) { $this->data = $array; - $this->isNewEntry = true; - $record = new $this->options['name']($this); - $this->isNewEntry = false; + $record = new $this->options['name']($this, true); $this->data = array(); return $record; } @@ -1118,14 +1112,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { $data = $stmt->fetch(PDO::FETCH_NUM); return isset($data[0])?$data[0]:1; } - /** - * return whether or not a newly created object is new or not - * - * @return boolean - */ - final public function isNewEntry() { - return $this->isNewEntry; - } /** * returns simple cached query *