diff --git a/lib/Doctrine/Hydrate/Array.php b/lib/Doctrine/Hydrate/Array.php new file mode 100644 index 000000000..8940064c2 --- /dev/null +++ b/lib/Doctrine/Hydrate/Array.php @@ -0,0 +1,48 @@ +. + */ + +/** + * Doctrine_Hydrate_Array + * defines an array fetching strategy for Doctrine_Hydrate + * + * @package Doctrine + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + * @author Konsta Vesterinen + */ +class Doctrine_Hydrate_Array +{ + public function getElementCollection($component) + { + return array(); + } + public function getElement(array $data, $component) + { + return $data; + } + public function flush() + { + + } +} diff --git a/lib/Doctrine/Hydrate/Record.php b/lib/Doctrine/Hydrate/Record.php new file mode 100644 index 000000000..3d08e788e --- /dev/null +++ b/lib/Doctrine/Hydrate/Record.php @@ -0,0 +1,68 @@ +. + */ + +/** + * Doctrine_Hydrate_Record + * defines a record fetching strategy for Doctrine_Hydrate + * + * @package Doctrine + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + * @author Konsta Vesterinen + */ +class Doctrine_Hydrate_Record +{ + protected $_collections = array(); + + protected $_records = array(); + + public function getElementCollection($component) + { + $coll = new Doctrine_Collection($component); + $this->_collections[] = $coll; + + return $coll; + } + public function getElement(array $data, $component) + { + $record = new $component(); + + $record->hydrate($data); + $this->_records[] = $record; + + return $record; + } + public function flush() + { + // take snapshots from all initialized collections + foreach (array_unique($this->_collections) as $c) { + $c->takeSnapshot(); + } + + foreach ($this->_records as $record) { + $record->state(Doctrine_Record::STATE_CLEAN); + } + + } +}