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
public function execute($params = null)
{
$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);
if ( ! $skip) {
......
This diff is collapsed.
......@@ -43,7 +43,7 @@ class Doctrine_Hydrate_Array
}
public function isIdentifiable(array $data, Doctrine_Table $table)
{
return true;
return (! empty($data));
}
public function registerCollection($coll)
{
......
......@@ -46,7 +46,7 @@ class Doctrine_Hydrate_Record
return $coll;
}
public function registerCollection($coll)
public function registerCollection(Doctrine_Collection $coll)
{
$this->_collections[] = $coll;
}
......@@ -76,19 +76,17 @@ class Doctrine_Hydrate_Record
}
return true;
}
public function getElement(array $data, $component)
{
if ( ! isset($this->_tables[$component])) {
$this->_tables[$component] = Doctrine_Manager::getInstance()->getTable($component);
$this->_tables[$component]->setAttribute(Doctrine::ATTR_LOAD_REFERENCES, false);
}
$this->_tables[$component]->setData($data);
$record = $this->_tables[$component]->getRecord();
$this->_records[] = $record;
$this->_tables[$component]->setAttribute(Doctrine::ATTR_LOAD_REFERENCES, false);
return $record;
}
public function flush()
......
......@@ -234,6 +234,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
*/
public function parseQueryPart($queryPartName, $queryPart, $append = false)
{
// sanity check
if ($queryPart === '' || $queryPart === null) {
throw new Doctrine_Query_Exception('Empty ' . $queryPartName . ' part given.');
......
......@@ -288,4 +288,17 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate
{
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
{
return self::$_null;
}
/**
* _index
*
* @return integer
*/
public static function _index()
{
return self::$_index;
}
/**
* setUp
* this method is used for setting up relations and attributes
......
......@@ -857,13 +857,26 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$key = array($key);
}
$found = false;
foreach ($key as $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];
}
if ($found) {
$this->data = array();
$recordName = $this->getClassnameToReturn();
$record = new $recordName($this, true);
return $record;
}
$id = implode(' ', $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