1
0
mirror of synced 2024-12-14 15:16:04 +03:00
This commit is contained in:
chtito 2006-11-06 07:06:10 +00:00
parent db4634557f
commit 63d84e18e9
2 changed files with 3 additions and 18 deletions

View File

@ -126,14 +126,13 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* open connections * open connections
* @throws Doctrine_Record_Exception if the cleanData operation fails somehow * @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) { if(isset($table) && $table instanceof Doctrine_Table) {
$this->_table = $table; $this->_table = $table;
$exists = ( ! $this->_table->isNewEntry());
} else { } else {
$this->_table = Doctrine_Manager::getInstance()->getCurrentConnection()->getTable(get_class($this)); $this->_table = Doctrine_Manager::getInstance()->getCurrentConnection()->getTable(get_class($this));
$exists = false;
} }
$exists = !$isNewEntry;
// Check if the current connection has the records table in its registry // Check if the current connection has the records table in its registry
// If not this record is only used for creating table definition and setting up // If not this record is only used for creating table definition and setting up

View File

@ -31,10 +31,6 @@
* @version 1.0 alpha * @version 1.0 alpha
*/ */
class Doctrine_Table extends Doctrine_Configurable implements Countable { 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 * @var array $data temporary data which is then loaded into Doctrine_Record::$data
*/ */
@ -761,9 +757,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
*/ */
public function create(array $array = array()) { public function create(array $array = array()) {
$this->data = $array; $this->data = $array;
$this->isNewEntry = true; $record = new $this->options['name']($this, true);
$record = new $this->options['name']($this);
$this->isNewEntry = false;
$this->data = array(); $this->data = array();
return $record; return $record;
} }
@ -1108,14 +1102,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$data = $stmt->fetch(PDO::FETCH_NUM); $data = $stmt->fetch(PDO::FETCH_NUM);
return isset($data[0])?$data[0]:1; 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 * returns simple cached query
* *