Commit d4c12c35 authored by zYne's avatar zYne

new DQL Hydration algorithm !

parent 881788f3
...@@ -201,7 +201,7 @@ class Doctrine_Db_Statement implements Doctrine_Adapter_Statement_Interface ...@@ -201,7 +201,7 @@ class Doctrine_Db_Statement implements Doctrine_Adapter_Statement_Interface
public function execute($params = null) public function execute($params = null)
{ {
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::EXECUTE, $this->stmt->queryString, $params); $event = new Doctrine_Db_Event($this, Doctrine_Db_Event::EXECUTE, $this->stmt->queryString, $params);
//print $this->stmt->queryString . print_r($params, true) . "<br>"; // print $this->stmt->queryString . print_r($params, true) . "<br>";
$skip = $this->adapter->getListener()->onPreExecute($event); $skip = $this->adapter->getListener()->onPreExecute($event);
if ( ! $skip) { if ( ! $skip) {
......
This diff is collapsed.
...@@ -43,7 +43,7 @@ class Doctrine_Hydrate_Array ...@@ -43,7 +43,7 @@ class Doctrine_Hydrate_Array
} }
public function isIdentifiable(array $data, Doctrine_Table $table) public function isIdentifiable(array $data, Doctrine_Table $table)
{ {
return true; return (! empty($data));
} }
public function registerCollection($coll) public function registerCollection($coll)
{ {
......
...@@ -46,7 +46,7 @@ class Doctrine_Hydrate_Record ...@@ -46,7 +46,7 @@ class Doctrine_Hydrate_Record
return $coll; return $coll;
} }
public function registerCollection($coll) public function registerCollection(Doctrine_Collection $coll)
{ {
$this->_collections[] = $coll; $this->_collections[] = $coll;
} }
...@@ -76,18 +76,16 @@ class Doctrine_Hydrate_Record ...@@ -76,18 +76,16 @@ class Doctrine_Hydrate_Record
} }
return true; return true;
} }
public function getElement(array $data, $component) public function getElement(array $data, $component)
{ {
if ( ! isset($this->_tables[$component])) { if ( ! isset($this->_tables[$component])) {
$this->_tables[$component] = Doctrine_Manager::getInstance()->getTable($component); $this->_tables[$component] = Doctrine_Manager::getInstance()->getTable($component);
$this->_tables[$component]->setAttribute(Doctrine::ATTR_LOAD_REFERENCES, false);
} }
$this->_tables[$component]->setData($data); $this->_tables[$component]->setData($data);
$record = $this->_tables[$component]->getRecord(); $record = $this->_tables[$component]->getRecord();
$this->_records[] = $record; $this->_records[] = $record;
$this->_tables[$component]->setAttribute(Doctrine::ATTR_LOAD_REFERENCES, false);
return $record; return $record;
} }
......
...@@ -233,7 +233,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -233,7 +233,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
* @return Doctrine_Query this object * @return Doctrine_Query this object
*/ */
public function parseQueryPart($queryPartName, $queryPart, $append = false) public function parseQueryPart($queryPartName, $queryPart, $append = false)
{ {
// sanity check // sanity check
if ($queryPart === '' || $queryPart === null) { if ($queryPart === '' || $queryPart === null) {
throw new Doctrine_Query_Exception('Empty ' . $queryPartName . ' part given.'); throw new Doctrine_Query_Exception('Empty ' . $queryPartName . ' part given.');
......
...@@ -288,4 +288,17 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate ...@@ -288,4 +288,17 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate
{ {
return $this->parseQueryPart('offset', $offset); return $this->parseQueryPart('offset', $offset);
} }
/**
* parseQueryPart
* parses given DQL query part
*
* @param string $queryPartName the name of the query part
* @param string $queryPart query part to be parsed
* @param boolean $append whether or not to append the query part to its stack
* if false is given, this method will overwrite
* the given query part stack with $queryPart
* @return Doctrine_Query this object
*/
abstract public function parseQueryPart($queryPartName, $queryPart, $append = false);
} }
...@@ -229,6 +229,15 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -229,6 +229,15 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
{ {
return self::$_null; return self::$_null;
} }
/**
* _index
*
* @return integer
*/
public static function _index()
{
return self::$_index;
}
/** /**
* setUp * setUp
* this method is used for setting up relations and attributes * this method is used for setting up relations and attributes
......
...@@ -857,13 +857,26 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -857,13 +857,26 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$key = array($key); $key = array($key);
} }
$found = false;
foreach ($key as $k) { foreach ($key as $k) {
if ( ! isset($this->data[$k])) { if ( ! isset($this->data[$k])) {
throw new Doctrine_Table_Exception("Primary key value for $k wasn't found"); // primary key column not found return new record
$found = true;
break;
} }
$id[] = $this->data[$k]; $id[] = $this->data[$k];
} }
if ($found) {
$this->data = array();
$recordName = $this->getClassnameToReturn();
$record = new $recordName($this, true);
return $record;
}
$id = implode(' ', $id); $id = implode(' ', $id);
if (isset($this->identityMap[$id])) { if (isset($this->identityMap[$id])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment