1
0
mirror of synced 2025-02-01 04:51:45 +03:00

Doctrine_Record renamed. Hydration refactored. Other refactorings.

This commit is contained in:
romanb 2008-05-13 21:20:34 +00:00
parent ad0d24ff57
commit 7ffd4140cd
285 changed files with 1295 additions and 914 deletions

View File

@ -289,7 +289,7 @@ final class Doctrine
/** /**
* FETCHMODE_RECORD * FETCHMODE_RECORD
* *
* Specifies that the fetch method shall return Doctrine_Record * Specifies that the fetch method shall return Doctrine_Entity
* objects as the elements of the result set. * objects as the elements of the result set.
* *
* This is the default fetchmode. * This is the default fetchmode.
@ -471,6 +471,14 @@ final class Doctrine
* @see self::ATTR_HYDRATE * @see self::ATTR_HYDRATE
*/ */
const HYDRATE_NONE = 4; const HYDRATE_NONE = 4;
/* new hydration modes. move to Query class when it's time. */
//const HYDRATE_IDENTITY_OBJECT = 1; // default, auto-adds PKs, produces object graphs
//const HYDRATE_IDENTITY_ARRAY = 2; // auto-adds PKs, produces array graphs
//const HYDRATE_SCALAR = 3; // produces flat result list with scalar values
//const HYDRATE_SINGLE_SCALAR = 4; // produces a single scalar value
//const HYDRATE_NONE = 5; // produces a result set as it's returned by the db
/** /**
* VALIDATE CONSTANTS * VALIDATE CONSTANTS
@ -709,8 +717,8 @@ final class Doctrine
* *
* Get all the loaded models, you can provide an array of classes or it will use get_declared_classes() * Get all the loaded models, you can provide an array of classes or it will use get_declared_classes()
* *
* Will filter through an array of classes and return the Doctrine_Records out of them. * Will filter through an array of classes and return the Doctrine_Entitys out of them.
* If you do not specify $classes it will return all of the currently loaded Doctrine_Records * If you do not specify $classes it will return all of the currently loaded Doctrine_Entitys
* *
* @return array $loadedModels * @return array $loadedModels
*/ */
@ -747,7 +755,7 @@ final class Doctrine
/** /**
* isValidModelClass * isValidModelClass
* *
* Checks if what is passed is a valid Doctrine_Record * Checks if what is passed is a valid Doctrine_Entity
* Will load class in to memory in order to inflect it and find out information about the class * Will load class in to memory in order to inflect it and find out information about the class
* *
* @param mixed $class Can be a string named after the class, an instance of the class, or an instance of the class reflected * @param mixed $class Can be a string named after the class, an instance of the class, or an instance of the class reflected
@ -755,7 +763,7 @@ final class Doctrine
*/ */
public static function isValidModelClass($class) public static function isValidModelClass($class)
{ {
if ($class instanceof Doctrine_Record) { if ($class instanceof Doctrine_Entity) {
$class = get_class($class); $class = get_class($class);
} }
@ -766,10 +774,10 @@ final class Doctrine
if ($class instanceof ReflectionClass) { if ($class instanceof ReflectionClass) {
// Skip the following classes // Skip the following classes
// - abstract classes // - abstract classes
// - not a subclass of Doctrine_Record // - not a subclass of Doctrine_Entity
// - don't have a setTableDefinition method // - don't have a setTableDefinition method
if (!$class->isAbstract() && if (!$class->isAbstract() &&
$class->isSubClassOf('Doctrine_Record')) { $class->isSubClassOf('Doctrine_Entity')) {
return true; return true;
} }
@ -805,7 +813,7 @@ final class Doctrine
/** /**
* generateModelsFromDb * generateModelsFromDb
* *
* method for importing existing schema to Doctrine_Record classes * method for importing existing schema to Doctrine_Entity classes
* *
* @param string $directory Directory to write your models to * @param string $directory Directory to write your models to
* @param array $databases Array of databases to generate models for * @param array $databases Array of databases to generate models for

View File

@ -55,11 +55,11 @@ class Doctrine_AuditLog extends Doctrine_Record_Generator
/** /**
* Get the version * Get the version
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @param mixed $version * @param mixed $version
* @return array An array with version information * @return array An array with version information
*/ */
public function getVersion(Doctrine_Record $record, $version) public function getVersion(Doctrine_Entity $record, $version)
{ {
$className = $this->_options['className']; $className = $this->_options['className'];

View File

@ -22,7 +22,7 @@
/** /**
* Doctrine_Builder_Record * Doctrine_Builder_Record
* *
* Import builder is responsible of building Doctrine_Record classes * Import builder is responsible of building Doctrine_Entity classes
* based on a database schema. * based on a database schema.
* *
* @package Doctrine * @package Doctrine
@ -93,7 +93,7 @@ class Doctrine_Builder_Record
* *
* @var string * @var string
*/ */
protected $_baseClassName = 'Doctrine_Record'; protected $_baseClassName = 'Doctrine_Entity';
/** /**
* tpl * tpl
@ -270,7 +270,7 @@ END;
} }
/* /*
* Build the table definition of a Doctrine_Record object * Build the table definition of a Doctrine_Entity object
* *
* @param string $table * @param string $table
* @param array $tableColumns * @param array $tableColumns

View File

@ -137,6 +137,14 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
* @var array $columns * @var array $columns
*/ */
protected $_mappedColumns = array(); protected $_mappedColumns = array();
/**
* The mapped embedded values (value objects).
*
* @var array
* @TODO Implementation (Value Object support)
*/
protected $_mappedEmbeddedValues = array();
/** /**
* An array of field names. used to look up field names from column names. * An array of field names. used to look up field names from column names.
@ -171,7 +179,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
protected $_tree; protected $_tree;
/** /**
* Cached column count, Doctrine_Record uses this column count when * Cached column count, Doctrine_Entity uses this column count when
* determining its state. * determining its state.
* *
* @var integer * @var integer
@ -1571,7 +1579,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
* binds query parts to given component * binds query parts to given component
* *
* @param array $queryParts an array of pre-bound query parts * @param array $queryParts an array of pre-bound query parts
* @return Doctrine_Record this object * @return Doctrine_Entity this object
*/ */
public function bindQueryParts(array $queryParts) public function bindQueryParts(array $queryParts)
{ {
@ -1585,7 +1593,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
* *
* @param string $queryPart * @param string $queryPart
* @param mixed $value * @param mixed $value
* @return Doctrine_Record this object * @return Doctrine_Entity this object
*/ */
public function bindQueryPart($queryPart, $value) public function bindQueryPart($queryPart, $value)
{ {
@ -1719,7 +1727,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
* *
* @param mixed $constraint either a SQL constraint portion or an array of CHECK constraints * @param mixed $constraint either a SQL constraint portion or an array of CHECK constraints
* @param string $name optional constraint name * @param string $name optional constraint name
* @return Doctrine_Record this object * @return Doctrine_Entity this object
* @todo Should be done through $_tableOptions * @todo Should be done through $_tableOptions
*/ */
public function check($constraint, $name = null) public function check($constraint, $name = null)
@ -1834,7 +1842,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
* @param string $componentName the name of the related component * @param string $componentName the name of the related component
* @param string $options relation options * @param string $options relation options
* @see Doctrine_Relation::_$definition * @see Doctrine_Relation::_$definition
* @return Doctrine_Record this object * @return Doctrine_Entity this object
*/ */
public function hasOne() public function hasOne()
{ {
@ -1850,7 +1858,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
* @param string $componentName the name of the related component * @param string $componentName the name of the related component
* @param string $options relation options * @param string $options relation options
* @see Doctrine_Relation::_$definition * @see Doctrine_Relation::_$definition
* @return Doctrine_Record this object * @return Doctrine_Entity this object
*/ */
public function hasMany() public function hasMany()
{ {

View File

@ -79,7 +79,7 @@ class Doctrine_ClassMetadata_Factory
$parentClasses = array(); $parentClasses = array();
$loadedParentClass = false; $loadedParentClass = false;
while ($parentClass = get_parent_class($parentClass)) { while ($parentClass = get_parent_class($parentClass)) {
if ($parentClass == 'Doctrine_Record') { if ($parentClass == 'Doctrine_Entity') {
break; break;
} }
if (isset($classes[$parentClass])) { if (isset($classes[$parentClass])) {
@ -159,7 +159,7 @@ class Doctrine_ClassMetadata_Factory
$className = $name; $className = $name;
// get parent classes // get parent classes
do { do {
if ($className === 'Doctrine_Record') { if ($className === 'Doctrine_Entity') {
break; break;
} else if ($className == $name) { } else if ($className == $name) {
continue; continue;

View File

@ -58,7 +58,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
/** /**
* This record this collection is attached to, if any. * This record this collection is attached to, if any.
* *
* @var Doctrine_Record * @var Doctrine_Entity
*/ */
protected $reference; protected $reference;
@ -308,7 +308,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* *
* @return void * @return void
*/ */
public function setReference(Doctrine_Record $record, Doctrine_Relation $relation) public function setReference(Doctrine_Entity $record, Doctrine_Relation $relation)
{ {
$this->reference = $record; $this->reference = $record;
$this->relation = $relation; $this->relation = $relation;
@ -368,7 +368,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
/** /**
* *
*/ */
public function search(Doctrine_Record $record) public function search(Doctrine_Entity $record)
{ {
return array_search($record, $this->data, true); return array_search($record, $this->data, true);
} }
@ -388,7 +388,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* Collection also maps referential information to newly created records * Collection also maps referential information to newly created records
* *
* @param mixed $key the key of the element * @param mixed $key the key of the element
* @return Doctrine_Record return a specified record * @return Doctrine_Entity return a specified record
*/ */
public function get($key) public function get($key)
{ {
@ -481,15 +481,15 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
/** /**
* set * set
* @param integer $key * @param integer $key
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return void * @return void
* @internal Can't type-hint the second parameter to Doctrine_Record because we need * @internal Can't type-hint the second parameter to Doctrine_Entity because we need
* to adhere to the Doctrine_Access::set() signature. * to adhere to the Doctrine_Access::set() signature.
*/ */
public function set($key, $record) public function set($key, $record)
{ {
if ( ! $record instanceOf Doctrine_Record) { if ( ! $record instanceOf Doctrine_Entity) {
throw new Doctrine_Collection_Exception('Value variable in set is not an instance of Doctrine_Record'); throw new Doctrine_Collection_Exception('Value variable in set is not an instance of Doctrine_Entity');
} }
if (isset($this->referenceField)) { if (isset($this->referenceField)) {
@ -500,14 +500,14 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
/** /**
* adds a record to collection * adds a record to collection
* @param Doctrine_Record $record record to be added * @param Doctrine_Entity $record record to be added
* @param string $key optional key for the record * @param string $key optional key for the record
* @return boolean * @return boolean
*/ */
public function add($record, $key = null) public function add($record, $key = null)
{ {
if ( ! $record instanceof Doctrine_Record) { if ( ! $record instanceof Doctrine_Entity) {
throw new Doctrine_Record_Exception('Value variable in set is not an instance of Doctrine_Record.'); throw new Doctrine_Record_Exception('Value variable in set is not an instance of Doctrine_Entity.');
} }
if (isset($this->referenceField)) { if (isset($this->referenceField)) {

View File

@ -96,7 +96,7 @@ abstract class Doctrine_Collection_Iterator implements Iterator
/** /**
* returns the current record * returns the current record
* *
* @return Doctrine_Record * @return Doctrine_Entity
*/ */
public function current() public function current()
{ {

View File

@ -20,7 +20,7 @@
*/ */
/** /**
* Doctrine_Collection_Offset * Doctrine_Collection_Offset
* Collection of Doctrine_Record objects. * Collection of Doctrine_Entity objects.
* *
* @package Doctrine * @package Doctrine
* @subpackage Collection * @subpackage Collection

View File

@ -144,6 +144,13 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
/* /*
* ----------- EntityManager attributes --------------- * ----------- EntityManager attributes ---------------
*/ */
/**
* Enter description here...
*
* @var array
*/
private static $_ems = array();
/** /**
* The metadata factory is used to retrieve the metadata of entity classes. * The metadata factory is used to retrieve the metadata of entity classes.
* *
@ -1129,14 +1136,26 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
} }
/* /*
* ----------- EntityManager methods --------------- * ----------- EntityManager methods ---------------
*/ */
/**
* Gets the EntityManager that is responsible for the Entity.
*
* @param string $entityName
* @return EntityManager
*/
public static function getManagerForEntity($entityName)
{
// ...
}
/** /**
* query * query
* queries the database using Doctrine Query Language * queries the database using Doctrine Query Language
* returns a collection of Doctrine_Record objects * returns a collection of Doctrine_Entity objects
* *
* <code> * <code>
* $users = $conn->query('SELECT u.* FROM User u'); * $users = $conn->query('SELECT u.* FROM User u');
@ -1148,7 +1167,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param array $params query parameters * @param array $params query parameters
* @param int $hydrationMode Doctrine::FETCH_ARRAY or Doctrine::FETCH_RECORD * @param int $hydrationMode Doctrine::FETCH_ARRAY or Doctrine::FETCH_RECORD
* @see Doctrine_Query * @see Doctrine_Query
* @return Doctrine_Collection Collection of Doctrine_Record objects * @return Doctrine_Collection Collection of Doctrine_Entity objects
* @todo package:orm * @todo package:orm
*/ */
public function query($query, array $params = array(), $hydrationMode = null) public function query($query, array $params = array(), $hydrationMode = null)
@ -1174,7 +1193,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @param string $query DQL query * @param string $query DQL query
* @param array $params query parameters * @param array $params query parameters
* @see Doctrine_Query * @see Doctrine_Query
* @return Doctrine_Record|false Doctrine_Record object on success, * @return Doctrine_Entity|false Doctrine_Entity object on success,
* boolean false on failure * boolean false on failure
*/ */
public function queryOne($query, array $params = array()) public function queryOne($query, array $params = array())
@ -1301,7 +1320,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* *
* create creates a record * create creates a record
* @param string $name component name * @param string $name component name
* @return Doctrine_Record Doctrine_Record object * @return Doctrine_Entity Doctrine_Entity object
* @todo Any strong reasons why this should not be removed? * @todo Any strong reasons why this should not be removed?
* @todo package:orm * @todo package:orm
*/ */
@ -1377,12 +1396,12 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$this->exported = array(); $this->exported = array();
} }
public function save(Doctrine_Record $entity, $conn = null) public function save(Doctrine_Entity $entity, $conn = null)
{ {
$this->getMapper($entity->getClassName())->save($entity, $conn); $this->getMapper($entity->getClassName())->save($entity, $conn);
} }
public function remove(Doctrine_Record $entity, $conn = null) public function remove(Doctrine_Entity $entity, $conn = null)
{ {
$this->getMapper($entity->getClassName())->delete($entity, $conn); $this->getMapper($entity->getClassName())->delete($entity, $conn);
} }
@ -1392,17 +1411,17 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
return $this->getMapper($entityName)->create($data); return $this->getMapper($entityName)->create($data);
} }
public function detach(Doctrine_Record $entity) public function detach(Doctrine_Entity $entity)
{ {
$this->getMapper($entity->getClassName())->detach($entity); $this->getMapper($entity->getClassName())->detach($entity);
} }
public function removeRecord(Doctrine_Record $entity) public function removeRecord(Doctrine_Entity $entity)
{ {
$this->getMapper($entity->getClassName())->removeRecord($entity); $this->getMapper($entity->getClassName())->removeRecord($entity);
} }
public function manage(Doctrine_Record $entity) public function manage(Doctrine_Entity $entity)
{ {
$this->getMapper($entity->getClassName())->manage($entity); $this->getMapper($entity->getClassName())->manage($entity);
} }
@ -1503,6 +1522,77 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
return $repository; return $repository;
} }
/**
* createEntity
* First checks if record exists in identityMap, if not
* returns a new record.
*
* @return Doctrine_Entity
*/
public function createEntity2($className, array $data)
{
$className = $this->_getClassnameToReturn($data, $className);
$classMetadata = $this->getClassMetadata($className);
if ( ! empty($data)) {
$identifierFieldNames = $classMetadata->getIdentifier();
$isNew = false;
foreach ($identifierFieldNames as $fieldName) {
if ( ! isset($data[$fieldName])) {
// id field not found return new entity
$isNew = true;
break;
}
$id[] = $data[$fieldName];
}
if ($isNew) {
return new $className(true, $data);
}
$idHash = $this->unitOfWork->getIdentifierHash($id);
if ($entity = $this->unitOfWork->tryGetByIdHash($idHash,
$classMetadata->getRootClassName())) {
// @todo return $entity; the one in-memory is the most recent.
$entity->hydrate($data);
} else {
$entity = new $className(false, $data);
$this->unitOfWork->registerIdentity($entity);
}
$data = array();
} else {
$entity = new $className(true, $data);
}
return $entity;
}
/**
* Check the dataset for a discriminator column to determine the correct
* class to instantiate. If no discriminator column is found, the given
* classname will be returned.
*
* @return string The name of the class to instantiate.
* @todo Can be optimized performance-wise.
* @todo Move to EntityManager::createEntity()
*/
protected function _getClassnameToReturn(array $data, $className)
{
$class = $this->getClassMetadata($className);
$discCol = $class->getInheritanceOption('discriminatorColumn');
if ( ! $discCol) {
return $className;
}
$discMap = $class->getInheritanceOption('discriminatorMap');
if (isset($data[$discCol], $discMap[$data[$discCol]])) {
return $discMap[$data[$discCol]];
} else {
return $className;
}
}
/* /*

View File

@ -119,7 +119,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
/** /**
* Register a new entity. * Register a new entity.
*/ */
public function registerNew(Doctrine_Record $entity) public function registerNew(Doctrine_Entity $entity)
{ {
if ( ! $entity->identifier()) { if ( ! $entity->identifier()) {
throw new Doctrine_Connection_Exception("Entity without identity " throw new Doctrine_Connection_Exception("Entity without identity "
@ -136,7 +136,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
$this->_newEntities[$oid] = $entity; $this->_newEntities[$oid] = $entity;
} }
public function isRegisteredNew(Doctrine_Record $entity) public function isRegisteredNew(Doctrine_Entity $entity)
{ {
return isset($this->_newEntities[$entity->getOid()]); return isset($this->_newEntities[$entity->getOid()]);
} }
@ -144,7 +144,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
/** /**
* Registers a clean entity. * Registers a clean entity.
*/ */
public function registerClean(Doctrine_Record $entity) public function registerClean(Doctrine_Entity $entity)
{ {
$this->registerIdentity($entity); $this->registerIdentity($entity);
} }
@ -152,7 +152,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
/** /**
* Registers a dirty entity. * Registers a dirty entity.
*/ */
public function registerDirty(Doctrine_Record $entity) public function registerDirty(Doctrine_Entity $entity)
{ {
if ( ! $entity->identifier()) { if ( ! $entity->identifier()) {
throw new Doctrine_Connection_Exception("Entity without identity " throw new Doctrine_Connection_Exception("Entity without identity "
@ -167,7 +167,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
} }
} }
public function isRegisteredDirty(Doctrine_Record $entity) public function isRegisteredDirty(Doctrine_Entity $entity)
{ {
return isset($this->_dirtyEntities[$entity->getOid()]); return isset($this->_dirtyEntities[$entity->getOid()]);
} }
@ -175,7 +175,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
/** /**
* Registers a deleted entity. * Registers a deleted entity.
*/ */
public function registerRemoved(Doctrine_Record $entity) public function registerRemoved(Doctrine_Entity $entity)
{ {
if ($entity->isTransient()) { if ($entity->isTransient()) {
return; return;
@ -194,7 +194,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
} }
} }
public function isRegisteredRemoved(Doctrine_Record $entity) public function isRegisteredRemoved(Doctrine_Entity $entity)
{ {
return isset($this->_removedEntities[$entity->getOid()]); return isset($this->_removedEntities[$entity->getOid()]);
} }
@ -342,7 +342,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
* Adds an entity to the pool of managed entities. * Adds an entity to the pool of managed entities.
* @deprecated * @deprecated
*/ */
public function manage(Doctrine_Record $entity) public function manage(Doctrine_Entity $entity)
{ {
$oid = $entity->getOid(); $oid = $entity->getOid();
if ( ! isset($this->_managedEntities[$oid])) { if ( ! isset($this->_managedEntities[$oid])) {
@ -357,7 +357,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
* @return boolean whether ot not the operation was successful * @return boolean whether ot not the operation was successful
* @deprecated * @deprecated
*/ */
public function detach(Doctrine_Record $entity) public function detach(Doctrine_Entity $entity)
{ {
$oid = $entity->getOid(); $oid = $entity->getOid();
if ( ! isset($this->_managedEntities[$oid])) { if ( ! isset($this->_managedEntities[$oid])) {
@ -386,7 +386,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
* the entity in question is already managed. * the entity in question is already managed.
* @throws Doctrine_Connection_Exception If the entity has no (database) identity. * @throws Doctrine_Connection_Exception If the entity has no (database) identity.
*/ */
public function registerIdentity(Doctrine_Record $entity) public function registerIdentity(Doctrine_Entity $entity)
{ {
$idHash = $this->getIdentifierHash($entity->identifier()); $idHash = $this->getIdentifierHash($entity->identifier());
if ( ! $idHash) { if ( ! $idHash) {
@ -406,7 +406,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
$this->_identityMap[$entityName] = array(); $this->_identityMap[$entityName] = array();
} }
public function unregisterIdentity(Doctrine_Record $entity) public function unregisterIdentity(Doctrine_Entity $entity)
{ {
$idHash = $this->getIdentifierHash($entity->identifier()); $idHash = $this->getIdentifierHash($entity->identifier());
if ( ! $idHash) { if ( ! $idHash) {
@ -443,10 +443,10 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
/** /**
* Checks whether an entity is registered in the identity map. * Checks whether an entity is registered in the identity map.
* *
* @param Doctrine_Record $entity * @param Doctrine_Entity $entity
* @return boolean * @return boolean
*/ */
public function contains(Doctrine_Record $entity) public function contains(Doctrine_Entity $entity)
{ {
$id = implode(' ', $entity->identifier()); $id = implode(' ', $entity->identifier());
if ( ! $id) { if ( ! $id) {

View File

@ -242,13 +242,13 @@ class Doctrine_Data
/** /**
* isRelation * isRelation
* *
* Check if a fieldName on a Doctrine_Record is a relation, if it is we return that relationData * Check if a fieldName on a Doctrine_Entity is a relation, if it is we return that relationData
* *
* @param string $Doctrine_Record * @param string $Doctrine_Entity
* @param string $fieldName * @param string $fieldName
* @return void * @return void
*/ */
public function isRelation(Doctrine_Record $record, $fieldName) public function isRelation(Doctrine_Entity $record, $fieldName)
{ {
$relations = $record->getTable()->getRelations(); $relations = $record->getTable()->getRelations();
@ -267,7 +267,7 @@ class Doctrine_Data
/** /**
* purge * purge
* *
* Purge all data for loaded models or for the passed array of Doctrine_Records * Purge all data for loaded models or for the passed array of Doctrine_Entitys
* *
* @param string $models * @param string $models
* @return void * @return void

View File

@ -289,7 +289,7 @@ class Doctrine_Data_Import extends Doctrine_Data
} }
} }
public function populateDummyRecord(Doctrine_Record $record) public function populateDummyRecord(Doctrine_Entity $record)
{ {
$lorem = explode(' ', "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem $lorem = explode(' ', "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum has been the industry's standard dummy text ever since the 1500s, when an Ipsum has been the industry's standard dummy text ever since the 1500s, when an

View File

@ -1,6 +1,6 @@
<?php <?php
/* /*
* $Id$ * $Id: Record.php 4342 2008-05-08 14:17:35Z romanb $
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -20,7 +20,7 @@
*/ */
/** /**
* Doctrine_Record * Doctrine_Entity
* All record classes should inherit this super class * All record classes should inherit this super class
* *
* @package Doctrine * @package Doctrine
@ -29,12 +29,12 @@
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org * @link www.phpdoctrine.org
* @since 1.0 * @since 2.0
* @version $Revision$ * @version $Revision: 4342 $
* @todo Rename to "Entity". Split up into "Entity" and "ActiveEntity (extends Entity)"??? * @todo Rename to "Entity". Split up into "Entity" and "ActiveEntity (extends Entity)"???
* @todo Remove as many methods as possible. * @todo Remove as many methods as possible.
*/ */
abstract class Doctrine_Record extends Doctrine_Access implements Countable, IteratorAggregate, Serializable abstract class Doctrine_Entity extends Doctrine_Access implements Countable, IteratorAggregate, Serializable
{ {
/** /**
* STATE CONSTANTS * STATE CONSTANTS
@ -42,39 +42,39 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
/** /**
* DIRTY STATE * DIRTY STATE
* a Doctrine_Record is in dirty state when its properties are changed * a Doctrine_Entity is in dirty state when its properties are changed
*/ */
const STATE_DIRTY = 1; const STATE_DIRTY = 1;
/** /**
* TDIRTY STATE * TDIRTY STATE
* a Doctrine_Record is in transient dirty state when it is created * a Doctrine_Entity is in transient dirty state when it is created
* and some of its fields are modified but it is NOT yet persisted into database * and some of its fields are modified but it is NOT yet persisted into database
*/ */
const STATE_TDIRTY = 2; const STATE_TDIRTY = 2;
/** /**
* CLEAN STATE * CLEAN STATE
* a Doctrine_Record is in clean state when all of its properties are loaded from the database * a Doctrine_Entity is in clean state when all of its properties are loaded from the database
* and none of its properties are changed * and none of its properties are changed
*/ */
const STATE_CLEAN = 3; const STATE_CLEAN = 3;
/** /**
* PROXY STATE * PROXY STATE
* a Doctrine_Record is in proxy state when its properties are not fully loaded * a Doctrine_Entity is in proxy state when its properties are not fully loaded
*/ */
const STATE_PROXY = 4; const STATE_PROXY = 4;
/** /**
* NEW TCLEAN * NEW TCLEAN
* a Doctrine_Record is in transient clean state when it is created and none of its fields are modified * a Doctrine_Entity is in transient clean state when it is created and none of its fields are modified
*/ */
const STATE_TCLEAN = 5; const STATE_TCLEAN = 5;
/** /**
* LOCKED STATE * LOCKED STATE
* a Doctrine_Record is temporarily locked during deletes and saves * a Doctrine_Entity is temporarily locked during deletes and saves
* *
* This state is used internally to ensure that circular deletes * This state is used internally to ensure that circular deletes
* and saves will not cause infinite loops * and saves will not cause infinite loops
@ -119,7 +119,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
protected $_class; protected $_class;
/** /**
* * The name of the Entity.
*
* @var string
*/ */
protected $_entityName; protected $_entityName;
@ -146,7 +148,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
/** /**
* The values array, aggregate values and such are mapped into this array. * The values array, aggregate values and such are mapped into this array.
* *
* @var array * @var array
* @todo Remove.
*/ */
protected $_values = array(); protected $_values = array();
@ -206,15 +209,19 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @throws Doctrine_Connection_Exception if object is created using the new operator and there are no * @throws Doctrine_Connection_Exception if object is created using the new operator and there are no
* open connections * open connections
* @throws Doctrine_Record_Exception if the cleanData operation fails somehow * @throws Doctrine_Record_Exception if the cleanData operation fails somehow
* @todo Remove all parameters.
*/ */
public function __construct($isNewEntry = true, array $data = array()) public function __construct($isNewEntry = true, array $data = array())
{ {
$this->_entityName = get_class($this); $this->_entityName = get_class($this);
$this->_em = Doctrine_Manager::getInstance()->getCurrentConnection(); $this->_em = Doctrine_Manager::getInstance()->getCurrentConnection();
// future: $this->_em = Doctrine_EntityManager::getManagerForEntity($this->_entityName);
$this->_class = $this->_em->getClassMetadata($this->_entityName); $this->_class = $this->_em->getClassMetadata($this->_entityName);
$this->_oid = self::$_index++; $this->_oid = self::$_index++;
// The following code inits data, id and state
// get the data array // get the data array
$this->_data = $data; $this->_data = $data;
@ -227,24 +234,25 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if ($isNewEntry) { if ($isNewEntry) {
if ($count > count($this->_values)) { if ($count > count($this->_values)) {
$this->_state = Doctrine_Record::STATE_TDIRTY; $this->_state = Doctrine_Entity::STATE_TDIRTY;
} else { } else {
$this->_state = Doctrine_Record::STATE_TCLEAN; $this->_state = Doctrine_Entity::STATE_TCLEAN;
} }
// set the default values for this record // set the default values for this record
$this->assignDefaultValues(); $this->assignDefaultValues();
} else { } else {
// TODO: registerClean() on UnitOfWork // TODO: registerClean() on UnitOfWork
$this->_state = Doctrine_Record::STATE_CLEAN; $this->_state = Doctrine_Entity::STATE_CLEAN;
if ($count < $this->_class->getColumnCount()) { if ($count < $this->_class->getColumnCount()) {
$this->_state = Doctrine_Record::STATE_PROXY; $this->_state = Doctrine_Entity::STATE_PROXY;
} }
} }
//--
self::$_useAutoAccessorOverride = false; // @todo read from attribute the first time self::$_useAutoAccessorOverride = false; // @todo read from attribute the first time
$this->_em->manage($this); $this->_em->manage($this); // @todo Remove
$this->construct(); $this->construct(); // @todo Remove
} }
/** /**
@ -450,7 +458,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
{ {
if ($stack !== null) { if ($stack !== null) {
if ( ! ($stack instanceof Doctrine_Validator_ErrorStack)) { if ( ! ($stack instanceof Doctrine_Validator_ErrorStack)) {
throw new Doctrine_Record_Exception('Argument should be an instance of Doctrine_Validator_ErrorStack.'); throw new Doctrine_Entity_Exception('Argument should be an instance of Doctrine_Validator_ErrorStack.');
} }
$this->_errorStack = $stack; $this->_errorStack = $stack;
} else { } else {
@ -464,7 +472,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* *
* @param boolean $overwrite whether or not to overwrite the already set values * @param boolean $overwrite whether or not to overwrite the already set values
* @return boolean * @return boolean
* @todo Maybe better placed in the Mapper? * @todo Job of EntityManager.
*/ */
public function assignDefaultValues($overwrite = false) public function assignDefaultValues($overwrite = false)
{ {
@ -481,7 +489,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if ($value === Doctrine_Null::$INSTANCE || $overwrite) { if ($value === Doctrine_Null::$INSTANCE || $overwrite) {
$this->_data[$column] = $default; $this->_data[$column] = $default;
$this->_modified[] = $column; $this->_modified[] = $column;
$this->_state = Doctrine_Record::STATE_TDIRTY; $this->_state = Doctrine_Entity::STATE_TDIRTY;
} }
} }
} }
@ -494,7 +502,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* *
* @param array $data data array to be cleaned * @param array $data data array to be cleaned
* @return array $tmp values cleaned from data * @return array $tmp values cleaned from data
* @todo Maybe better placed in the Mapper? * @todo Remove. Should not be necessary. Slows down instantiation.
*/ */
public function cleanData(&$data) public function cleanData(&$data)
{ {
@ -601,7 +609,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this->_data = array_merge($this->_data, $this->_id); $this->_data = array_merge($this->_data, $this->_id);
foreach ($this->_data as $k => $v) { foreach ($this->_data as $k => $v) {
if ($v instanceof Doctrine_Record && $this->_class->getTypeOf($k) != 'object') { if ($v instanceof Doctrine_Entity && $this->_class->getTypeOf($k) != 'object') {
unset($vars['_data'][$k]); unset($vars['_data'][$k]);
} else if ($v === Doctrine_Null::$INSTANCE) { } else if ($v === Doctrine_Null::$INSTANCE) {
unset($vars['_data'][$k]); unset($vars['_data'][$k]);
@ -632,7 +640,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* Reconstructs the entity from it's serialized form. * Reconstructs the entity from it's serialized form.
* This method is automatically called everytime the entity is unserialized. * This method is automatically called everytime the entity is unserialized.
* *
* @param string $serialized Doctrine_Record as serialized string * @param string $serialized Doctrine_Entity as serialized string
* @throws Doctrine_Record_Exception if the cleanData operation fails somehow * @throws Doctrine_Record_Exception if the cleanData operation fails somehow
* @return void * @return void
*/ */
@ -687,7 +695,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* returns / assigns the state of this record * returns / assigns the state of this record
* *
* @param integer|string $state if set, this method tries to set the record state to $state * @param integer|string $state if set, this method tries to set the record state to $state
* @see Doctrine_Record::STATE_* constants * @see Doctrine_Entity::STATE_* constants
* *
* @throws Doctrine_Record_State_Exception if trying to set an unknown state * @throws Doctrine_Record_State_Exception if trying to set an unknown state
* @return null|integer * @return null|integer
@ -707,7 +715,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
} else if (is_string($state)) { } else if (is_string($state)) {
$upper = strtoupper($state); $upper = strtoupper($state);
$const = 'Doctrine_Record::STATE_' . $upper; $const = 'Doctrine_Entity::STATE_' . $upper;
if (defined($const)) { if (defined($const)) {
$this->_state = constant($const); $this->_state = constant($const);
} else { } else {
@ -715,8 +723,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
} }
} }
if ($this->_state === Doctrine_Record::STATE_TCLEAN || if ($this->_state === Doctrine_Entity::STATE_TCLEAN ||
$this->_state === Doctrine_Record::STATE_CLEAN) { $this->_state === Doctrine_Entity::STATE_CLEAN) {
$this->_modified = array(); $this->_modified = array();
} }
@ -735,8 +743,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @throws Doctrine_Record_Exception When the refresh operation fails (when the database row * @throws Doctrine_Record_Exception When the refresh operation fails (when the database row
* this record represents does not exist anymore) * this record represents does not exist anymore)
* @return boolean * @return boolean
* @todo Logic is better placed in the Mapper. Just forward to the mapper. * @todo Implementation to EntityManager.
* @todo ActiveRecord method. * @todo ActiveEntity method.
*/ */
public function refresh($deep = false) public function refresh($deep = false)
{ {
@ -773,7 +781,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this->_extractIdentifier(); $this->_extractIdentifier();
$this->_state = Doctrine_Record::STATE_CLEAN; $this->_state = Doctrine_Entity::STATE_CLEAN;
return $this; return $this;
} }
@ -785,9 +793,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @param string $name name of a related component. * @param string $name name of a related component.
* if set, this method only refreshes the specified related component * if set, this method only refreshes the specified related component
* *
* @return Doctrine_Record this object * @return Doctrine_Entity this object
* @todo Logic is better placed in the Mapper. Just forward to the mapper. * @todo Implementation to EntityManager.
* @todo ActiveRecord method. * @todo ActiveEntity method.
*/ */
public function refreshRelated($name = null) public function refreshRelated($name = null)
{ {
@ -823,7 +831,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
} }
/** /**
* * @todo Remove.
*/ */
public function getValues() public function getValues()
{ {
@ -831,25 +839,136 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
} }
/** /**
* rawGet * Gets the value of a field (regular field or reference).
* returns the value of a property, if the property is not yet loaded * If the property is not yet loaded this method does NOT load it.
* this method does NOT load it *
* NOTE: Use of this method from outside the scope of an extending class
* is strongly discouraged.
* *
* @param $name name of the property * @param $name name of the property
* @throws Doctrine_Record_Exception if trying to get an unknown property * @throws Doctrine_Entity_Exception if trying to get an unknown field
* @return mixed * @return mixed
*/ */
public function rawGet($fieldName) public function rawGet($fieldName)
{ {
if ( ! isset($this->_data[$fieldName])) { if (isset($this->_data[$fieldName])) {
throw new Doctrine_Record_Exception('Unknown property '. $fieldName); return $this->rawGetField($fieldName);
} else if (isset($this->_references[$fieldName])) {
return $this->rawGetReference($fieldName);
} else {
throw Doctrine_Entity_Exception::unknownField($fieldName);
} }
}
/**
* Gets the value of a field.
*
* NOTE: Use of this method from outside the scope of an extending class
* is strongly discouraged. This method does NOT check whether the field
* exists.
*
* @param string $fieldName
* @return mixed
*/
public function rawGetField($fieldName)
{
if ($this->_data[$fieldName] === Doctrine_Null::$INSTANCE) { if ($this->_data[$fieldName] === Doctrine_Null::$INSTANCE) {
return null; return null;
} }
return $this->_data[$fieldName]; return $this->_data[$fieldName];
} }
/**
* Sets the value of a field.
*
* NOTE: Use of this method from outside the scope of an extending class
* is strongly discouraged. This method does NOT check whether the field
* exists.
*
* @param string $fieldName
* @param mixed $value
*/
public function rawSetField($fieldName, $value)
{
$this->_data[$fieldName] = $value;
}
/**
* Gets a reference to another Entity.
*
* NOTE: Use of this method from outside the scope of an extending class
* is strongly discouraged. This method does NOT check whether the reference
* exists.
*
* @param unknown_type $fieldName
*/
public function rawGetReference($fieldName)
{
if ($this->_references[$fieldName] === Doctrine_Null::$INSTANCE) {
return null;
}
return $this->_references[$fieldName];
}
/**
* Sets a reference to another Entity.
*
* NOTE: Use of this method from outside the scope of an extending class
* is strongly discouraged.
*
* @param unknown_type $fieldName
* @param unknown_type $value
* @todo Refactor. What about composite keys?
*/
public function rawSetReference($name, $value)
{
if ($value === Doctrine_Null::$INSTANCE) {
$this->_references[$name] = $value;
return;
}
$rel = $this->_class->getRelation($name);
// one-to-many or one-to-one relation
if ($rel instanceof Doctrine_Relation_ForeignKey ||
$rel instanceof Doctrine_Relation_LocalKey) {
if ( ! $rel->isOneToOne()) {
// one-to-many relation found
if ( ! $value instanceof Doctrine_Collection) {
throw Doctrine_Entity_Exception::invalidValueForOneToManyReference();
}
if (isset($this->_references[$name])) {
$this->_references[$name]->setData($value->getData());
return $this;
}
} else {
$relatedTable = $value->getTable();
$foreignFieldName = $rel->getForeignFieldName();
$localFieldName = $rel->getLocalFieldName();
// one-to-one relation found
if ( ! ($value instanceof Doctrine_Entity)) {
throw Doctrine_Entity_Exception::invalidValueForOneToOneReference();
}
if ($rel instanceof Doctrine_Relation_LocalKey) {
$idFieldNames = $value->getTable()->getIdentifier();
if ( ! empty($foreignFieldName) && $foreignFieldName != $idFieldNames[0]) {
$this->set($localFieldName, $value->rawGet($foreignFieldName), false);
} else {
$this->set($localFieldName, $value, false);
}
} else {
$value->set($foreignFieldName, $this, false);
}
}
} else if ($rel instanceof Doctrine_Relation_Association) {
if ( ! ($value instanceof Doctrine_Collection)) {
throw Doctrine_Entity_Exception::invalidValueForManyToManyReference();
}
}
$this->_references[$name] = $value;
}
/** /**
* load * load
@ -860,10 +979,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/ */
public function load() public function load()
{ {
// only load the data from database if the Doctrine_Record is in proxy state // only load the data from database if the Doctrine_Entity is in proxy state
if ($this->_state == Doctrine_Record::STATE_PROXY) { if ($this->_state == Doctrine_Entity::STATE_PROXY) {
$this->refresh(); $this->refresh();
$this->_state = Doctrine_Record::STATE_CLEAN; $this->_state = Doctrine_Entity::STATE_CLEAN;
return true; return true;
} }
return false; return false;
@ -966,7 +1085,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
/** /**
* set * set
* method for altering properties and Doctrine_Record references * method for altering properties and Doctrine_Entity references
* if the load parameter is set to false this method will not try to load uninitialized record data * if the load parameter is set to false this method will not try to load uninitialized record data
* *
* @param mixed $name name of the property or reference * @param mixed $name name of the property or reference
@ -976,12 +1095,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @throws Doctrine_Record_Exception if trying to set a value for unknown property / related component * @throws Doctrine_Record_Exception if trying to set a value for unknown property / related component
* @throws Doctrine_Record_Exception if trying to set a value of wrong type for related component * @throws Doctrine_Record_Exception if trying to set a value of wrong type for related component
* *
* @return Doctrine_Record * @return Doctrine_Entity
*/ */
public function set($fieldName, $value, $load = true) public function set($fieldName, $value, $load = true)
{ {
if (isset($this->_data[$fieldName])) { if (isset($this->_data[$fieldName])) {
if ($value instanceof Doctrine_Record) { if ($value instanceof Doctrine_Entity) {
$type = $this->_class->getTypeOf($fieldName); $type = $this->_class->getTypeOf($fieldName);
// FIXME: composite key support // FIXME: composite key support
$ids = $value->identifier(); $ids = $value->identifier();
@ -1012,17 +1131,17 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
} }
switch ($this->_state) { switch ($this->_state) {
case Doctrine_Record::STATE_CLEAN: case Doctrine_Entity::STATE_CLEAN:
$this->_state = Doctrine_Record::STATE_DIRTY; $this->_state = Doctrine_Entity::STATE_DIRTY;
break; break;
case Doctrine_Record::STATE_TCLEAN: case Doctrine_Entity::STATE_TCLEAN:
$this->_state = Doctrine_Record::STATE_TDIRTY; $this->_state = Doctrine_Entity::STATE_TDIRTY;
break; break;
} }
} }
} else { } else {
try { try {
$this->_coreSetRelated($fieldName, $value); $this->rawSetReference($fieldName, $value);
} catch (Doctrine_Relation_Exception $e) { } catch (Doctrine_Relation_Exception $e) {
//echo $e->getTraceAsString(); //echo $e->getTraceAsString();
//echo "<br/><br/>"; //echo "<br/><br/>";
@ -1035,67 +1154,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
} }
} }
/**
* Sets a related component.
* @todo Refactor. What about composite keys?
*/
private function _coreSetRelated($name, $value)
{
if ($value === Doctrine_Null::$INSTANCE) {
$this->_references[$name] = $value;
return;
}
$rel = $this->_class->getRelation($name);
// one-to-many or one-to-one relation
if ($rel instanceof Doctrine_Relation_ForeignKey ||
$rel instanceof Doctrine_Relation_LocalKey) {
if ( ! $rel->isOneToOne()) {
// one-to-many relation found
if ( ! $value instanceof Doctrine_Collection) {
throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second"
. " argument should be an instance of Doctrine_Collection when"
. " setting one-to-many references.");
}
if (isset($this->_references[$name])) {
$this->_references[$name]->setData($value->getData());
return $this;
}
} else {
if ($value !== Doctrine_Null::$INSTANCE) {
$relatedTable = $value->getTable();
$foreignFieldName = $rel->getForeignFieldName();
$localFieldName = $rel->getLocalFieldName();
// one-to-one relation found
if ( ! ($value instanceof Doctrine_Record)) {
throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(),"
. " second argument should be an instance of Doctrine_Record"
. " or Doctrine_Null when setting one-to-one references.");
}
if ($rel instanceof Doctrine_Relation_LocalKey) {
$idFieldNames = $value->getTable()->getIdentifier();
if ( ! empty($foreignFieldName) && $foreignFieldName != $idFieldNames[0]) {
$this->set($localFieldName, $value->rawGet($foreignFieldName), false);
} else {
$this->set($localFieldName, $value, false);
}
} else {
$value->set($foreignFieldName, $this, false);
}
}
}
} else if ($rel instanceof Doctrine_Relation_Association) {
// join table relation found
if ( ! ($value instanceof Doctrine_Collection)) {
throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting many-to-many references.");
}
}
$this->_references[$name] = $value;
}
/** /**
* contains * contains
* *
@ -1132,7 +1190,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if (isset($this->_data[$fieldName])) { if (isset($this->_data[$fieldName])) {
$this->_data[$fieldName] = array(); $this->_data[$fieldName] = array();
} else if (isset($this->_references[$fieldName])) { } else if (isset($this->_references[$fieldName])) {
if ($this->_references[$fieldName] instanceof Doctrine_Record) { if ($this->_references[$fieldName] instanceof Doctrine_Entity) {
// todo: delete related record when saving $this // todo: delete related record when saving $this
$this->_references[$fieldName] = Doctrine_Null::$INSTANCE; $this->_references[$fieldName] = Doctrine_Null::$INSTANCE;
} else if ($this->_references[$fieldName] instanceof Doctrine_Collection) { } else if ($this->_references[$fieldName] instanceof Doctrine_Collection) {
@ -1157,7 +1215,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
/** /**
* Tries to save the object and all its related objects. * Tries to save the object and all its related objects.
* In contrast to Doctrine_Record::save(), this method does not * In contrast to Doctrine_Entity::save(), this method does not
* throw an exception when validation fails but returns TRUE on * throw an exception when validation fails but returns TRUE on
* success or FALSE on failure. * success or FALSE on failure.
* *
@ -1269,7 +1327,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$dataSet[$field] = $this->_class->enumIndex($field, $this->_data[$field]); $dataSet[$field] = $this->_class->enumIndex($field, $this->_data[$field]);
break; break;
default: default:
if ($this->_data[$field] instanceof Doctrine_Record) { if ($this->_data[$field] instanceof Doctrine_Entity) {
// FIXME: composite key support // FIXME: composite key support
$ids = $this->_data[$field]->identifier(); $ids = $this->_data[$field]->identifier();
$id = count($ids) > 0 ? array_pop($ids) : null; $id = count($ids) > 0 ? array_pop($ids) : null;
@ -1353,9 +1411,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
} }
} }
// [FIX] Prevent mapped Doctrine_Records from being displayed fully // [FIX] Prevent mapped Doctrine_Entitys from being displayed fully
foreach ($this->_values as $key => $value) { foreach ($this->_values as $key => $value) {
if ($value instanceof Doctrine_Record) { if ($value instanceof Doctrine_Entity) {
$a[$key] = $value->toArray($deep, $prefixKey); $a[$key] = $value->toArray($deep, $prefixKey);
} else { } else {
$a[$key] = $value; $a[$key] = $value;
@ -1410,14 +1468,14 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
/** /**
* synchronizeFromArray * synchronizeFromArray
* synchronizes a Doctrine_Record and its relations with data from an array * synchronizes a Doctrine_Entity and its relations with data from an array
* *
* it expects an array representation of a Doctrine_Record similar to the return * it expects an array representation of a Doctrine_Entity similar to the return
* value of the toArray() method. If the array contains relations it will create * value of the toArray() method. If the array contains relations it will create
* those that don't exist, update the ones that do, and delete the ones missing * those that don't exist, update the ones that do, and delete the ones missing
* on the array but available on the Doctrine_Record * on the array but available on the Doctrine_Entity
* *
* @param array $array representation of a Doctrine_Record * @param array $array representation of a Doctrine_Entity
* @todo ActiveRecord method. * @todo ActiveRecord method.
*/ */
public function synchronizeFromArray(array $array) public function synchronizeFromArray(array $array)
@ -1480,8 +1538,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/ */
public function exists() public function exists()
{ {
return ($this->_state !== Doctrine_Record::STATE_TCLEAN && return ($this->_state !== Doctrine_Entity::STATE_TCLEAN &&
$this->_state !== Doctrine_Record::STATE_TDIRTY); $this->_state !== Doctrine_Entity::STATE_TDIRTY);
} }
/** /**
@ -1513,8 +1571,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/ */
public function isDirty() public function isDirty()
{ {
return ($this->_state === Doctrine_Record::STATE_DIRTY || return ($this->_state === Doctrine_Entity::STATE_DIRTY ||
$this->_state === Doctrine_Record::STATE_TDIRTY); $this->_state === Doctrine_Entity::STATE_TDIRTY);
} }
/** /**
@ -1526,12 +1584,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/ */
public function isModified() public function isModified()
{ {
return ($this->_state === Doctrine_Record::STATE_DIRTY || return ($this->_state === Doctrine_Entity::STATE_DIRTY ||
$this->_state === Doctrine_Record::STATE_TDIRTY); $this->_state === Doctrine_Entity::STATE_TDIRTY);
} }
/** /**
* method for checking existence of properties and Doctrine_Record references * method for checking existence of properties and Doctrine_Entity references
* *
* @param mixed $name name of the property or reference * @param mixed $name name of the property or reference
* @return boolean * @return boolean
@ -1572,7 +1630,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
/** /**
* Creates a copy of the entity. * Creates a copy of the entity.
* *
* @return Doctrine_Record * @return Doctrine_Entity
* @todo ActiveRecord method. Implementation to EntityManager. * @todo ActiveRecord method. Implementation to EntityManager.
*/ */
public function copy($deep = true) public function copy($deep = true)
@ -1621,11 +1679,11 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if ($id === false) { if ($id === false) {
$this->_id = array(); $this->_id = array();
$this->_data = $this->cleanData($this->_data); $this->_data = $this->cleanData($this->_data);
$this->_state = Doctrine_Record::STATE_TCLEAN; $this->_state = Doctrine_Entity::STATE_TCLEAN;
$this->_modified = array(); $this->_modified = array();
} else if ($id === true) { } else if ($id === true) {
$this->_extractIdentifier(true); $this->_extractIdentifier(true);
$this->_state = Doctrine_Record::STATE_CLEAN; $this->_state = Doctrine_Entity::STATE_CLEAN;
$this->_modified = array(); $this->_modified = array();
} else { } else {
if (is_array($id)) { if (is_array($id)) {
@ -1639,7 +1697,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this->_id[$name] = $id; $this->_id[$name] = $id;
$this->_data[$name] = $id; $this->_data[$name] = $id;
} }
$this->_state = Doctrine_Record::STATE_CLEAN; $this->_state = Doctrine_Entity::STATE_CLEAN;
$this->_modified = array(); $this->_modified = array();
} }
} }
@ -1731,7 +1789,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @param string|array $callback valid callback * @param string|array $callback valid callback
* @param string $column column name * @param string $column column name
* @param mixed arg1 ... argN optional callback arguments * @param mixed arg1 ... argN optional callback arguments
* @return Doctrine_Record * @return Doctrine_Entity
* @todo Really needed/used? If not, remove. * @todo Really needed/used? If not, remove.
* @todo ActiveRecord method. (if at all) * @todo ActiveRecord method. (if at all)
*/ */
@ -1779,7 +1837,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* *
* @throws Doctrine_Record_Exception if given version does not exist * @throws Doctrine_Record_Exception if given version does not exist
* @param integer $version an integer > 1 * @param integer $version an integer > 1
* @return Doctrine_Record this object * @return Doctrine_Entity this object
* @todo Should go to the Versionable plugin. * @todo Should go to the Versionable plugin.
*/ */
public function revert($version) public function revert($version)
@ -1813,7 +1871,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* *
* @param string $alias related component alias * @param string $alias related component alias
* @param array $ids the identifiers of the related records * @param array $ids the identifiers of the related records
* @return Doctrine_Record this object * @return Doctrine_Entity this object
* @todo ActiveRecord method. * @todo ActiveRecord method.
*/ */
public function unlink($alias, $ids = array()) public function unlink($alias, $ids = array())
@ -1868,7 +1926,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* *
* @param string $alias related component alias * @param string $alias related component alias
* @param array $ids the identifiers of the related records * @param array $ids the identifiers of the related records
* @return Doctrine_Record this object * @return Doctrine_Entity this object
* @todo ActiveRecord method. * @todo ActiveRecord method.
*/ */
public function link($alias, array $ids) public function link($alias, array $ids)
@ -2001,8 +2059,17 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
return $this->_class; return $this->_class;
} }
/**
* Enter description here...
*
* @return unknown
*/
public function getEntityManager() public function getEntityManager()
{ {
if ( ! $this->_em) {
$this->_em = Doctrine_Manager::getInstance()->getCurrentConnection();
// future: $this->_em = Doctrine_EntityManager::getManagerForEntity($this->_entityName);
}
return $this->_em; return $this->_em;
} }

View File

@ -0,0 +1,28 @@
<?php
class Doctrine_Entity_Exception extends Doctrine_Exception
{
public static function unknownField($field)
{
return new self("Undefined field: '$field'.");
}
public static function invalidValueForOneToManyReference()
{
return new self("Invalid value. The value of a reference in a OneToMany "
. "association must be a Collection.");
}
public static function invalidValueForOneToOneReference()
{
return new self("Invalid value. The value of a reference in a OneToOne "
. "association must be an Entity.");
}
public static function invalidValueForManyToManyReference()
{
return new self("Invalid value. The value of a reference in a ManyToMany "
. "association must be a Collection.");
}
}
?>

View File

@ -63,11 +63,9 @@ class Doctrine_EntityRepository
} }
/** /**
* clear * Clears the repository, causing all managed entities to become detached.
* clears the first level cache (identityMap)
* *
* @return void * @return void
* @todo what about a more descriptive name? clearIdentityMap?
*/ */
public function clear() public function clear()
{ {
@ -77,9 +75,9 @@ class Doctrine_EntityRepository
/** /**
* Finds an entity by its primary key. * Finds an entity by its primary key.
* *
* @param $id database row id * @param $id The identifier.
* @param int $hydrationMode Doctrine::HYDRATE_ARRAY or Doctrine::HYDRATE_RECORD * @param int $hydrationMode The hydration mode to use.
* @return mixed Array or Doctrine_Record or false if no result * @return mixed Array or Doctrine_Entity or false if no result
* @todo Remove. Move to EntityRepository. * @todo Remove. Move to EntityRepository.
*/ */
public function find($id, $hydrationMode = null) public function find($id, $hydrationMode = null)

View File

@ -96,12 +96,12 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
/** /**
* onLoad * onLoad
* an event invoked when Doctrine_Record is being loaded from database * an event invoked when Doctrine_Entity is being loaded from database
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return void * @return void
*/ */
public function onLoad(Doctrine_Record $record) public function onLoad(Doctrine_Entity $record)
{ {
foreach ($this->_listeners as $listener) { foreach ($this->_listeners as $listener) {
$listener->onLoad($record); $listener->onLoad($record);
@ -110,13 +110,13 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
/** /**
* onPreLoad * onPreLoad
* an event invoked when Doctrine_Record is being loaded * an event invoked when Doctrine_Entity is being loaded
* from database but not yet initialized * from database but not yet initialized
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return void * @return void
*/ */
public function onPreLoad(Doctrine_Record $record) public function onPreLoad(Doctrine_Entity $record)
{ {
foreach ($this->_listeners as $listener) { foreach ($this->_listeners as $listener) {
$listener->onPreLoad($record); $listener->onPreLoad($record);
@ -125,12 +125,12 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
/** /**
* onSleep * onSleep
* an event invoked when Doctrine_Record is serialized * an event invoked when Doctrine_Entity is serialized
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return void * @return void
*/ */
public function onSleep(Doctrine_Record $record) public function onSleep(Doctrine_Entity $record)
{ {
foreach ($this->_listeners as $listener) { foreach ($this->_listeners as $listener) {
$listener->onSleep($record); $listener->onSleep($record);
@ -139,12 +139,12 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
/** /**
* onWakeUp * onWakeUp
* an event invoked when Doctrine_Record is unserialized * an event invoked when Doctrine_Entity is unserialized
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return void * @return void
*/ */
public function onWakeUp(Doctrine_Record $record) public function onWakeUp(Doctrine_Entity $record)
{ {
foreach ($this->_listeners as $listener) { foreach ($this->_listeners as $listener) {
$listener->onWakeUp($record); $listener->onWakeUp($record);

View File

@ -1030,13 +1030,13 @@ class Doctrine_Export extends Doctrine_Connection_Module
/** /**
* exportSchema * exportSchema
* method for exporting Doctrine_Record classes to a schema * method for exporting Doctrine_Entity classes to a schema
* *
* if the directory parameter is given this method first iterates * if the directory parameter is given this method first iterates
* recursively trhough the given directory in order to find any model classes * recursively trhough the given directory in order to find any model classes
* *
* Then it iterates through all declared classes and creates tables for the ones * Then it iterates through all declared classes and creates tables for the ones
* that extend Doctrine_Record and are not abstract classes * that extend Doctrine_Entity and are not abstract classes
* *
* @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS * @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS
* occurred during the create table operation * occurred during the create table operation
@ -1060,7 +1060,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
* FIXME: This method is a big huge hack. The sql needs to be executed in the correct order. I have some stupid logic to * FIXME: This method is a big huge hack. The sql needs to be executed in the correct order. I have some stupid logic to
* make sure they are in the right order. * make sure they are in the right order.
* *
* method for exporting Doctrine_Record classes to a schema * method for exporting Doctrine_Entity classes to a schema
* *
* @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS * @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS
* occurred during the create table operation * occurred during the create table operation
@ -1133,7 +1133,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
/** /**
* exportClassesSql * exportClassesSql
* method for exporting Doctrine_Record classes to a schema * method for exporting Doctrine_Entity classes to a schema
* *
* @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS * @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS
* occurred during the create table operation * occurred during the create table operation
@ -1244,13 +1244,13 @@ class Doctrine_Export extends Doctrine_Connection_Module
/** /**
* exportSql * exportSql
* returns the sql for exporting Doctrine_Record classes to a schema * returns the sql for exporting Doctrine_Entity classes to a schema
* *
* if the directory parameter is given this method first iterates * if the directory parameter is given this method first iterates
* recursively trhough the given directory in order to find any model classes * recursively trhough the given directory in order to find any model classes
* *
* Then it iterates through all declared classes and creates tables for the ones * Then it iterates through all declared classes and creates tables for the ones
* that extend Doctrine_Record and are not abstract classes * that extend Doctrine_Entity and are not abstract classes
* *
* @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS * @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS
* occurred during the create table operation * occurred during the create table operation

View File

@ -52,7 +52,7 @@ class Doctrine_Export_Schema
$array = array(); $array = array();
$parent = new ReflectionClass('Doctrine_Record'); $parent = new ReflectionClass('Doctrine_Entity');
$sql = array(); $sql = array();
$fks = array(); $fks = array();

View File

@ -30,7 +30,7 @@
* @link www.phpdoctrine.org * @link www.phpdoctrine.org
* @since 1.0 * @since 1.0
*/ */
class Doctrine_File extends Doctrine_Record class Doctrine_File extends Doctrine_Entity
{ {
public function setTableDefinition() public function setTableDefinition()
{ {

View File

@ -30,7 +30,7 @@
* @link www.phpdoctrine.org * @link www.phpdoctrine.org
* @since 1.0 * @since 1.0
*/ */
class Doctrine_File_Index extends Doctrine_Record class Doctrine_File_Index extends Doctrine_Entity
{ {
public function setTableDefinition() public function setTableDefinition()
{ {

View File

@ -58,22 +58,27 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
* ) * )
* @return mixed The created object/array graph. * @return mixed The created object/array graph.
*/ */
public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null) public function hydrateResultSet($parserResult)
{ {
if ($hydrationMode === null) { if ($parserResult->getHydrationMode() === null) {
$hydrationMode = $this->_hydrationMode; $hydrationMode = $this->_hydrationMode;
} else {
$hydrationMode = $parserResult->getHydrationMode();
} }
$stmt = $parserResult->getDatabaseStatement();
if ($hydrationMode == Doctrine::HYDRATE_NONE) { if ($hydrationMode == Doctrine::HYDRATE_NONE) {
return $stmt->fetchAll(PDO::FETCH_NUM); return $stmt->fetchAll(PDO::FETCH_NUM);
} }
$this->_tableAliases = $tableAliases; $this->_tableAliases = $parserResult->getTableToClassAliasMap();
$this->_queryComponents = $parserResult->getQueryComponents();
if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
$driver = new Doctrine_Hydrator_ArrayDriver(); $driver = new Doctrine_Hydrator_ArrayDriver();
} else { } else {
$driver = new Doctrine_Hydrator_RecordDriver(); $driver = new Doctrine_Hydrator_RecordDriver($this->_em);
} }
$event = new Doctrine_Event(null, Doctrine_Event::HYDRATE, null); $event = new Doctrine_Event(null, Doctrine_Event::HYDRATE, null);
@ -294,7 +299,7 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
end($coll); end($coll);
$prev[$dqlAlias] =& $coll[key($coll)]; $prev[$dqlAlias] =& $coll[key($coll)];
} }
} else if ($coll instanceof Doctrine_Record) { } else if ($coll instanceof Doctrine_Entity) {
$prev[$dqlAlias] = $coll; $prev[$dqlAlias] = $coll;
} else if (count($coll) > 0) { } else if (count($coll) > 0) {
$prev[$dqlAlias] = $coll->getLast(); $prev[$dqlAlias] = $coll->getLast();

View File

@ -55,14 +55,17 @@ abstract class Doctrine_Hydrator_Abstract
protected $_hydrationMode = Doctrine::HYDRATE_RECORD; protected $_hydrationMode = Doctrine::HYDRATE_RECORD;
protected $_nullObject; protected $_nullObject;
protected $_em;
/** /**
* constructor * constructor
* *
* @param Doctrine_Connection|null $connection * @param Doctrine_Connection|null $connection
*/ */
public function __construct() public function __construct(Doctrine_Connection $em)
{ {
$this->_em = $em;
$this->_nullObject = Doctrine_Null::$INSTANCE; $this->_nullObject = Doctrine_Null::$INSTANCE;
} }
@ -156,6 +159,6 @@ abstract class Doctrine_Hydrator_Abstract
* @param mixed $stmt * @param mixed $stmt
* @return array * @return array
*/ */
abstract public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null); abstract public function hydrateResultSet($parserResult);
} }

View File

@ -33,6 +33,7 @@
*/ */
class Doctrine_Hydrator_ArrayDriver class Doctrine_Hydrator_ArrayDriver
{ {
/** /**
* *
*/ */
@ -73,6 +74,52 @@ class Doctrine_Hydrator_ArrayDriver
} }
} }
public function addRelatedIndexedElement(array &$entity1, $property, array &$entity2,
$indexField)
{
$entity1[$property][$entity2[$indexField]] = $entity2;
}
public function addRelatedElement(array &$entity1, $property, array &$entity2)
{
$entity1[$property][] = $entity2;
}
public function setRelatedElement(array &$entity1, $property, &$entity2)
{
$entity1[$property] = $entity2;
}
public function isIndexKeyInUse(array &$entity, $assocField, $indexField)
{
return isset($entity[$assocField][$indexField]);
}
public function isFieldSet(array &$entity, $field)
{
return isset($entity[$field]);
}
public function getFieldValue(array &$entity, $field)
{
return $entity[$field];
}
public function &getReferenceValue(array &$entity, $field)
{
return $entity[$field];
}
public function addElementToIndexedCollection(array &$coll, array &$entity, $keyField)
{
$coll[$entity[$keyField]] = $entity;
}
public function addElementToCollection(array &$coll, array &$entity)
{
$coll[] = $entity;
}
/** /**
* *
*/ */

View File

@ -36,16 +36,17 @@ class Doctrine_Hydrator_RecordDriver
{ {
/** Collections initialized by the driver */ /** Collections initialized by the driver */
protected $_collections = array(); protected $_collections = array();
/** Mappers */
protected $_mappers = array();
/** Memory for initialized relations */ /** Memory for initialized relations */
private $_initializedRelations = array(); private $_initializedRelations = array();
/** Null object */ /** Null object */
private $_nullObject; private $_nullObject;
/** The EntityManager */
private $_em;
public function __construct() public function __construct(Doctrine_Connection $em)
{ {
$this->_nullObject = Doctrine_Null::$INSTANCE; $this->_nullObject = Doctrine_Null::$INSTANCE;
$this->_em = $em;
} }
public function getElementCollection($component) public function getElementCollection($component)
@ -68,15 +69,15 @@ class Doctrine_Hydrator_RecordDriver
} }
} }
public function initRelatedCollection(Doctrine_Record $record, $name) public function initRelatedCollection(Doctrine_Entity $entity, $name)
{ {
if ( ! isset($this->_initializedRelations[$record->getOid()][$name])) { if ( ! isset($this->_initializedRelations[$entity->getOid()][$name])) {
$relation = $record->getClassMetadata()->getRelation($name); $relation = $entity->getClassMetadata()->getRelation($name);
$relatedClass = $relation->getTable(); $relatedClass = $relation->getTable();
$coll = $this->getElementCollection($relatedClass->getClassName()); $coll = $this->getElementCollection($relatedClass->getClassName());
$coll->setReference($record, $relation); $coll->setReference($entity, $relation);
$record[$name] = $coll; $entity->rawSetReference($name, $coll);
$this->_initializedRelations[$record->getOid()][$name] = true; $this->_initializedRelations[$entity->getOid()][$name] = true;
} }
} }
@ -92,14 +93,54 @@ class Doctrine_Hydrator_RecordDriver
public function getElement(array $data, $className) public function getElement(array $data, $className)
{ {
$className = $this->_getClassnameToReturn($data, $className); return $this->_em->createEntity2($className, $data);
if ( ! isset($this->_mappers[$className])) { }
$this->_mappers[$className] = Doctrine_Manager::getInstance()->getMapper($className);
} public function addRelatedIndexedElement(Doctrine_Entity $entity1, $property,
Doctrine_Entity $entity2, $indexField)
$record = $this->_mappers[$className]->getRecord($data); {
$entity1->rawGetReference($property)->add($entity2, $entity2->rawGetField($indexField));
return $record; }
public function addRelatedElement(Doctrine_Entity $entity1, $property,
Doctrine_Entity $entity2)
{
$entity1->rawGetReference($property)->add($entity2);
}
public function setRelatedElement(Doctrine_Entity $entity1, $property, $entity2)
{
$entity1->rawSetReference($property, $entity2);
}
public function isIndexKeyInUse(Doctrine_Entity $entity, $assocField, $indexField)
{
return $entity->rawGetReference($assocField)->contains($indexField);
}
public function isFieldSet(Doctrine_Entity $entity, $field)
{
return $entity->contains($field);
}
public function getFieldValue(Doctrine_Entity $entity, $field)
{
return $entity->rawGetField($field);
}
public function getReferenceValue(Doctrine_Entity $entity, $field)
{
return $entity->rawGetReference($field);
}
public function addElementToIndexedCollection($coll, $entity, $keyField)
{
$coll->add($entity, $entity->rawGetField($keyField));
}
public function addElementToCollection($coll, $entity)
{
$coll->add($entity);
} }
public function flush() public function flush()
@ -109,35 +150,8 @@ class Doctrine_Hydrator_RecordDriver
$coll->takeSnapshot(); $coll->takeSnapshot();
} }
$this->_collections = array(); $this->_collections = array();
$this->_mappers = array();
$this->_initializedRelations = array(); $this->_initializedRelations = array();
} }
/**
* Check the dataset for a discriminator column to determine the correct
* class to instantiate. If no discriminator column is found, the given
* classname will be returned.
*
* @return string The name of the class to instantiate.
* @todo Can be optimized performance-wise.
*/
protected function _getClassnameToReturn(array $data, $className)
{
if ( ! isset($this->_mappers[$className])) {
$this->_mappers[$className] = Doctrine_Manager::getInstance()->getMapper($className);
}
$discCol = $this->_mappers[$className]->getClassMetadata()->getInheritanceOption('discriminatorColumn');
if ( ! $discCol) {
return $className;
}
$discMap = $this->_mappers[$className]->getClassMetadata()->getInheritanceOption('discriminatorMap');
if (isset($data[$discCol], $discMap[$data[$discCol]])) {
return $discMap[$data[$discCol]];
} else {
return $className;
}
}
} }

View File

@ -77,27 +77,32 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
* ) * )
* @return mixed The created object/array graph. * @return mixed The created object/array graph.
*/ */
public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null) public function hydrateResultSet($parserResult)
{ {
if ($hydrationMode === null) { if ($parserResult->getHydrationMode() === null) {
$hydrationMode = $this->_hydrationMode; $hydrationMode = $this->_hydrationMode;
} else {
$hydrationMode = $parserResult->getHydrationMode();
} }
$stmt = $parserResult->getDatabaseStatement();
if ($hydrationMode == Doctrine::HYDRATE_NONE) { if ($hydrationMode == Doctrine::HYDRATE_NONE) {
return $stmt->fetchAll(PDO::FETCH_NUM); return $stmt->fetchAll(PDO::FETCH_NUM);
} }
$this->_tableAliases = $tableAliases; $this->_tableAliases = $parserResult->getTableToClassAliasMap();
$this->_queryComponents = $parserResult->getQueryComponents();
if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
$driver = new Doctrine_Hydrator_ArrayDriver(); $driver = new Doctrine_Hydrator_ArrayDriver();
} else { } else {
$driver = new Doctrine_Hydrator_RecordDriver(); $driver = new Doctrine_Hydrator_RecordDriver($this->_em);
} }
$event = new Doctrine_Event(null, Doctrine_Event::HYDRATE, null); $event = new Doctrine_Event(null, Doctrine_Event::HYDRATE, null);
//$s = microtime(true); $s = microtime(true);
// Used variables during hydration // Used variables during hydration
reset($this->_queryComponents); reset($this->_queryComponents);
@ -120,7 +125,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
$idTemplate = array(); $idTemplate = array();
// Holds the resulting hydrated data structure // Holds the resulting hydrated data structure
if ($this->_isResultMixed) { if ($parserResult->isMixedQuery()) {
$result = array(); $result = array();
} else { } else {
$result = $driver->getElementCollection($rootComponentName); $result = $driver->getElementCollection($rootComponentName);
@ -171,21 +176,25 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
// do we need to index by a custom field? // do we need to index by a custom field?
if ($field = $this->_getCustomIndexField($rootAlias)) { if ($field = $this->_getCustomIndexField($rootAlias)) {
if (isset($result[$field])) { // TODO: must be checked in the parser. fields used in INDEXBY
// must be a) the primary key or b) unique & notnull
/*if (isset($result[$field])) {
throw Doctrine_Hydrator_Exception::nonUniqueKeyMapping(); throw Doctrine_Hydrator_Exception::nonUniqueKeyMapping();
} else if ( ! isset($element[$field])) { } else if ( ! isset($element[$field])) {
throw Doctrine_Hydrator_Exception::nonExistantFieldUsedAsIndex($field); throw Doctrine_Hydrator_Exception::nonExistantFieldUsedAsIndex($field);
} }*/
if ($this->_isResultMixed) { if ($parserResult->isMixedQuery()) {
$result[] = array($element[$field] => $element); $result[] = array(
$driver->getFieldValue($element, $field) => $element
);
} else { } else {
$result[$element[$field]] = $element; $driver->addElementToIndexedCollection($result, $element, $field);
} }
} else { } else {
if ($this->_isResultMixed) { if ($parserResult->isMixedQuery()) {
$result[] = array($element); $result[] = array($element);
} else { } else {
$result[] = $element; $driver->addElementToCollection($result, $element);
} }
} }
$identifierMap[$rootAlias][$id[$rootAlias]] = $driver->getLastKey($result); $identifierMap[$rootAlias][$id[$rootAlias]] = $driver->getLastKey($result);
@ -223,7 +232,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
$path = $parent . '.' . $dqlAlias; $path = $parent . '.' . $dqlAlias;
// pick the right element that will get the associated element attached // pick the right element that will get the associated element attached
if ($this->_isResultMixed && $parent == $rootAlias) { if ($parserResult->isMixedQuery() && $parent == $rootAlias) {
$key = key(reset($resultPointers)); $key = key(reset($resultPointers));
// TODO: Exception if $key === null ? // TODO: Exception if $key === null ?
$baseElement =& $resultPointers[$parent][$key]; $baseElement =& $resultPointers[$parent][$key];
@ -248,41 +257,44 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
//-- //--
if ($field = $this->_getCustomIndexField($dqlAlias)) { if ($field = $this->_getCustomIndexField($dqlAlias)) {
// TODO: we should check this earlier. Fields used in INDEXBY // TODO: must be checked in the parser. fields used in INDEXBY
// must be unique. Then this can be removed here. // must be a) the primary key or b) unique & notnull
if (isset($baseElement[$relationAlias][$field])) { /*if ($driver->isIndexKeyInUse($baseElement, $relationAlias, $field)) {
throw Doctrine_Hydrator_Exception::nonUniqueKeyMapping(); throw Doctrine_Hydrator_Exception::nonUniqueKeyMapping();
} else if ( ! isset($element[$field])) { } else if ( ! $driver->isFieldSet($element, $field)) {
throw Doctrine_Hydrator_Exception::nonExistantFieldUsedAsIndex($field); throw Doctrine_Hydrator_Exception::nonExistantFieldUsedAsIndex($field);
} }*/
$baseElement[$relationAlias][$element[$field]] = $element; $driver->addRelatedIndexedElement($baseElement, $relationAlias, $element, $field);
} else { } else {
$baseElement[$relationAlias][] = $element; $driver->addRelatedElement($baseElement, $relationAlias, $element);
} }
$identifierMap[$path][$id[$parent]][$id[$dqlAlias]] = $driver->getLastKey($baseElement[$relationAlias]); $identifierMap[$path][$id[$parent]][$id[$dqlAlias]] = $driver->getLastKey(
$driver->getReferenceValue($baseElement, $relationAlias));
} else { } else {
$index = $identifierMap[$path][$id[$parent]][$id[$dqlAlias]]; $index = $identifierMap[$path][$id[$parent]][$id[$dqlAlias]];
} }
} else if ( ! isset($baseElement[$relationAlias])) { } else if ( ! isset($baseElement[$relationAlias])) {
$baseElement[$relationAlias] = $driver->getNullPointer(); $driver->setRelatedElement($baseElement, $relationAlias,
$driver->getNullPointer());
} }
} else { } else {
// x-1 relation // x-1 relation
$oneToOne = true; $oneToOne = true;
if ( ! isset($nonemptyComponents[$dqlAlias])) { if ( ! isset($nonemptyComponents[$dqlAlias])) {
$baseElement[$relationAlias] = $driver->getNullPointer(); $driver->setRelatedElement($baseElement, $relationAlias,
} else if ( ! isset($baseElement[$relationAlias])) { $driver->getNullPointer());
$baseElement[$relationAlias] = $driver->getElement($data, $componentName); } else if ( ! $driver->isFieldSet($baseElement, $relationAlias)) {
$driver->setRelatedElement($baseElement, $relationAlias,
$driver->getElement($data, $componentName));
} }
} }
if ($baseElement[$relationAlias] !== null) { if (($coll =& $driver->getReferenceValue($baseElement, $relationAlias)) !== null) {
$coll =& $baseElement[$relationAlias];
$this->_setLastElement($resultPointers, $coll, $index, $dqlAlias, $oneToOne); $this->_setLastElement($resultPointers, $coll, $index, $dqlAlias, $oneToOne);
} }
} }
// append scalar values // append scalar values to mixed result sets
if (isset($scalars)) { if (isset($scalars)) {
$rowNumber = count($result) - 1; $rowNumber = count($result) - 1;
foreach ($scalars as $name => $value) { foreach ($scalars as $name => $value) {
@ -299,8 +311,8 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
$data['table']->setAttribute(Doctrine::ATTR_LOAD_REFERENCES, true); $data['table']->setAttribute(Doctrine::ATTR_LOAD_REFERENCES, true);
} }
//$e = microtime(true); $e = microtime(true);
//echo 'Hydration took: ' . ($e - $s) . ' for '.count($result).' records<br />'; echo 'Hydration took: ' . ($e - $s) . ' for '.count($result).' records' . PHP_EOL;
return $result; return $result;
} }
@ -339,7 +351,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
end($coll); end($coll);
$resultPointers[$dqlAlias] =& $coll[key($coll)]; $resultPointers[$dqlAlias] =& $coll[key($coll)];
} }
} else if ($coll instanceof Doctrine_Record) { } else if ($coll instanceof Doctrine_Entity) {
$resultPointers[$dqlAlias] = $coll; $resultPointers[$dqlAlias] = $coll;
} else if (count($coll) > 0) { } else if (count($coll) > 0) {
$resultPointers[$dqlAlias] = $coll->getLast(); $resultPointers[$dqlAlias] = $coll->getLast();

View File

@ -190,7 +190,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
/** /**
* importSchema * importSchema
* *
* method for importing existing schema to Doctrine_Record classes * method for importing existing schema to Doctrine_Entity classes
* *
* @param string $directory * @param string $directory
* @param array $databases * @param array $databases

View File

@ -23,7 +23,7 @@
* class Doctrine_Import_Schema * class Doctrine_Import_Schema
* *
* Different methods to import a XML schema. The logic behind using two different * Different methods to import a XML schema. The logic behind using two different
* methods is simple. Some people will like the idea of producing Doctrine_Record * methods is simple. Some people will like the idea of producing Doctrine_Entity
* objects directly, which is totally fine. But in fast and growing application, * objects directly, which is totally fine. But in fast and growing application,
* table definitions tend to be a little bit more volatile. importArr() can be used * table definitions tend to be a little bit more volatile. importArr() can be used
* to output a table definition in a PHP file. This file can then be stored * to output a table definition in a PHP file. This file can then be stored
@ -44,7 +44,7 @@ class Doctrine_Import_Schema
'packagesPath' => '', 'packagesPath' => '',
'generateBaseClasses' => true, 'generateBaseClasses' => true,
'baseClassesDirectory' => 'generated', 'baseClassesDirectory' => 'generated',
'baseClassName' => 'Doctrine_Record', 'baseClassName' => 'Doctrine_Entity',
'suffix' => '.php'); 'suffix' => '.php');
/** /**
@ -136,10 +136,10 @@ class Doctrine_Import_Schema
/** /**
* importSchema * importSchema
* *
* A method to import a Schema and translate it into a Doctrine_Record object * A method to import a Schema and translate it into a Doctrine_Entity object
* *
* @param string $schema The file containing the XML schema * @param string $schema The file containing the XML schema
* @param string $directory The directory where the Doctrine_Record class will be written * @param string $directory The directory where the Doctrine_Entity class will be written
* @param array $models Optional array of models to import * @param array $models Optional array of models to import
* *
* @return void * @return void

View File

@ -36,25 +36,25 @@ class Doctrine_Lib
* getRecordStateAsString * getRecordStateAsString
* *
* @param integer $state the state of record * @param integer $state the state of record
* @see Doctrine_Record::STATE_* constants * @see Doctrine_Entity::STATE_* constants
* @return string string representation of given state * @return string string representation of given state
*/ */
public static function getRecordStateAsString($state) public static function getRecordStateAsString($state)
{ {
switch ($state) { switch ($state) {
case Doctrine_Record::STATE_PROXY: case Doctrine_Entity::STATE_PROXY:
return "proxy"; return "proxy";
break; break;
case Doctrine_Record::STATE_CLEAN: case Doctrine_Entity::STATE_CLEAN:
return "persistent clean"; return "persistent clean";
break; break;
case Doctrine_Record::STATE_DIRTY: case Doctrine_Entity::STATE_DIRTY:
return "persistent dirty"; return "persistent dirty";
break; break;
case Doctrine_Record::STATE_TDIRTY: case Doctrine_Entity::STATE_TDIRTY:
return "transient dirty"; return "transient dirty";
break; break;
case Doctrine_Record::STATE_TCLEAN: case Doctrine_Entity::STATE_TCLEAN:
return "transient clean"; return "transient clean";
break; break;
} }
@ -63,12 +63,12 @@ class Doctrine_Lib
/** /**
* getRecordAsString * getRecordAsString
* *
* returns a string representation of Doctrine_Record object * returns a string representation of Doctrine_Entity object
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return string * @return string
*/ */
public static function getRecordAsString(Doctrine_Record $record) public static function getRecordAsString(Doctrine_Entity $record)
{ {
$r[] = '<pre>'; $r[] = '<pre>';
$r[] = 'Component : ' . $record->getTable()->getComponentName(); $r[] = 'Component : ' . $record->getTable()->getComponentName();

View File

@ -90,15 +90,15 @@ class Doctrine_Locking_Manager_Pessimistic
} }
/** /**
* Obtains a lock on a {@link Doctrine_Record} * Obtains a lock on a {@link Doctrine_Entity}
* *
* @param Doctrine_Record $record The record that has to be locked * @param Doctrine_Entity $record The record that has to be locked
* @param mixed $userIdent A unique identifier of the locking user * @param mixed $userIdent A unique identifier of the locking user
* @return boolean TRUE if the locking was successful, FALSE if another user * @return boolean TRUE if the locking was successful, FALSE if another user
* holds a lock on this record * holds a lock on this record
* @throws Doctrine_Locking_Exception If the locking failed due to database errors * @throws Doctrine_Locking_Exception If the locking failed due to database errors
*/ */
public function getLock(Doctrine_Record $record, $userIdent) public function getLock(Doctrine_Entity $record, $userIdent)
{ {
$objectType = $record->getTable()->getComponentName(); $objectType = $record->getTable()->getComponentName();
$key = $record->obtainIdentifier(); $key = $record->obtainIdentifier();
@ -160,14 +160,14 @@ class Doctrine_Locking_Manager_Pessimistic
} }
/** /**
* Releases a lock on a {@link Doctrine_Record} * Releases a lock on a {@link Doctrine_Entity}
* *
* @param Doctrine_Record $record The record for which the lock has to be released * @param Doctrine_Entity $record The record for which the lock has to be released
* @param mixed $userIdent The unique identifier of the locking user * @param mixed $userIdent The unique identifier of the locking user
* @return boolean TRUE if a lock was released, FALSE if no lock was released * @return boolean TRUE if a lock was released, FALSE if no lock was released
* @throws Doctrine_Locking_Exception If the release procedure failed due to database errors * @throws Doctrine_Locking_Exception If the release procedure failed due to database errors
*/ */
public function releaseLock(Doctrine_Record $record, $userIdent) public function releaseLock(Doctrine_Entity $record, $userIdent)
{ {
$objectType = $record->getTable()->getComponentName(); $objectType = $record->getTable()->getComponentName();
$key = $record->obtainIdentifier(); $key = $record->obtainIdentifier();
@ -235,7 +235,7 @@ class Doctrine_Locking_Manager_Pessimistic
* Gets the identifier that identifies the owner of the lock on the given * Gets the identifier that identifies the owner of the lock on the given
* record. * record.
* *
* @param Doctrine_Record $lockedRecord The record. * @param Doctrine_Entity $lockedRecord The record.
* @return mixed The unique user identifier that identifies the owner of the lock. * @return mixed The unique user identifier that identifies the owner of the lock.
*/ */
public function getLockOwner($lockedRecord) public function getLockOwner($lockedRecord)

View File

@ -68,6 +68,8 @@ class Doctrine_Mapper
* A list of registered entity listeners. * A list of registered entity listeners.
*/ */
private $_entityListeners = array(); private $_entityListeners = array();
private $_dataTemplate = array();
/** /**
@ -118,7 +120,7 @@ class Doctrine_Mapper
* *
* @param $array an array where keys are field names and * @param $array an array where keys are field names and
* values representing field values * values representing field values
* @return Doctrine_Record the created record object * @return Doctrine_Entity the created record object
*/ */
public function create(array $array = array()) public function create(array $array = array())
{ {
@ -146,7 +148,7 @@ class Doctrine_Mapper
return false; return false;
} }
public function notifyEntityListeners(Doctrine_Record $entity, $callback, $eventType) public function notifyEntityListeners(Doctrine_Entity $entity, $callback, $eventType)
{ {
if ($this->_entityListeners) { if ($this->_entityListeners) {
$event = new Doctrine_Event($entity, $eventType); $event = new Doctrine_Event($entity, $eventType);
@ -156,7 +158,7 @@ class Doctrine_Mapper
} }
} }
public function detach(Doctrine_Record $entity) public function detach(Doctrine_Entity $entity)
{ {
return $this->_conn->unitOfWork->detach($entity); return $this->_conn->unitOfWork->detach($entity);
} }
@ -192,11 +194,11 @@ class Doctrine_Mapper
* addRecord * addRecord
* adds a record to identity map * adds a record to identity map
* *
* @param Doctrine_Record $record record to be added * @param Doctrine_Entity $record record to be added
* @return boolean * @return boolean
* @todo Better name? registerRecord? Move elsewhere to the new location of the identity maps. * @todo Better name? registerRecord? Move elsewhere to the new location of the identity maps.
*/ */
public function addRecord(Doctrine_Record $record) public function addRecord(Doctrine_Entity $record)
{ {
if ($this->_conn->unitOfWork->contains($record)) { if ($this->_conn->unitOfWork->contains($record)) {
return false; return false;
@ -212,7 +214,7 @@ class Doctrine_Mapper
* @return boolean TRUE if the entity was previously not managed and is now managed, * @return boolean TRUE if the entity was previously not managed and is now managed,
* FALSE otherwise (the entity is already managed). * FALSE otherwise (the entity is already managed).
*/ */
public function manage(Doctrine_Record $record) public function manage(Doctrine_Entity $record)
{ {
return $this->_conn->unitOfWork->manage($record); return $this->_conn->unitOfWork->manage($record);
} }
@ -222,11 +224,11 @@ class Doctrine_Mapper
* removes a record from the identity map, returning true if the record * removes a record from the identity map, returning true if the record
* was found and removed and false if the record wasn't found. * was found and removed and false if the record wasn't found.
* *
* @param Doctrine_Record $record record to be removed * @param Doctrine_Entity $record record to be removed
* @return boolean * @return boolean
* @todo Move elsewhere to the new location of the identity maps. * @todo Move elsewhere to the new location of the identity maps.
*/ */
public function removeRecord(Doctrine_Record $record) public function removeRecord(Doctrine_Entity $record)
{ {
if ($this->_conn->unitOfWork->contains($record)) { if ($this->_conn->unitOfWork->contains($record)) {
$this->_conn->unitOfWork->unregisterIdentity($record); $this->_conn->unitOfWork->unregisterIdentity($record);
@ -241,7 +243,7 @@ class Doctrine_Mapper
* First checks if record exists in identityMap, if not * First checks if record exists in identityMap, if not
* returns a new record. * returns a new record.
* *
* @return Doctrine_Record * @return Doctrine_Entity
*/ */
public function getRecord(array $data) public function getRecord(array $data)
{ {
@ -401,7 +403,7 @@ class Doctrine_Mapper
* Hydrates the given data into the entity. * Hydrates the given data into the entity.
* *
*/ */
/*public function hydrate(Doctrine_Record $entity, array $data) /*public function hydrate(Doctrine_Entity $entity, array $data)
{ {
$this->_values = array_merge($this->_values, $this->cleanData($data)); $this->_values = array_merge($this->_values, $this->cleanData($data));
$this->_data = array_merge($this->_data, $data); $this->_data = array_merge($this->_data, $data);
@ -456,12 +458,12 @@ class Doctrine_Mapper
/** /**
* Saves an entity and all it's related entities. * Saves an entity and all it's related entities.
* *
* @param Doctrine_Record $record The entity to save. * @param Doctrine_Entity $record The entity to save.
* @param Doctrine_Connection $conn The connection to use. Will default to the mapper's * @param Doctrine_Connection $conn The connection to use. Will default to the mapper's
* connection. * connection.
* @throws Doctrine_Mapper_Exception If the mapper is unable to save the given entity. * @throws Doctrine_Mapper_Exception If the mapper is unable to save the given entity.
*/ */
public function save(Doctrine_Record $record, Doctrine_Connection $conn = null) public function save(Doctrine_Entity $record, Doctrine_Connection $conn = null)
{ {
if ( ! ($record instanceof $this->_domainClassName)) { if ( ! ($record instanceof $this->_domainClassName)) {
throw new Doctrine_Mapper_Exception("Mapper of type " . $this->_domainClassName . " throw new Doctrine_Mapper_Exception("Mapper of type " . $this->_domainClassName . "
@ -473,11 +475,11 @@ class Doctrine_Mapper
} }
$state = $record->state(); $state = $record->state();
if ($state === Doctrine_Record::STATE_LOCKED) { if ($state === Doctrine_Entity::STATE_LOCKED) {
return false; return false;
} }
$record->state(Doctrine_Record::STATE_LOCKED); $record->state(Doctrine_Entity::STATE_LOCKED);
try { try {
$conn->beginInternalTransaction(); $conn->beginInternalTransaction();
@ -492,7 +494,7 @@ class Doctrine_Mapper
} }
$state = $record->state(); $state = $record->state();
$record->state(Doctrine_Record::STATE_LOCKED); $record->state(Doctrine_Entity::STATE_LOCKED);
foreach ($saveLater as $fk) { foreach ($saveLater as $fk) {
$alias = $fk->getAlias(); $alias = $fk->getAlias();
@ -521,23 +523,23 @@ class Doctrine_Mapper
/** /**
* Inserts or updates an entity, depending on it's state. * Inserts or updates an entity, depending on it's state.
* *
* @param Doctrine_Record $record The entity to insert/update. * @param Doctrine_Entity $record The entity to insert/update.
*/ */
protected function _insertOrUpdate(Doctrine_Record $record) protected function _insertOrUpdate(Doctrine_Entity $record)
{ {
$record->preSave(); $record->preSave();
$this->notifyEntityListeners($record, 'preSave', Doctrine_Event::RECORD_SAVE); $this->notifyEntityListeners($record, 'preSave', Doctrine_Event::RECORD_SAVE);
switch ($record->state()) { switch ($record->state()) {
case Doctrine_Record::STATE_TDIRTY: case Doctrine_Entity::STATE_TDIRTY:
$this->_insert($record); $this->_insert($record);
break; break;
case Doctrine_Record::STATE_DIRTY: case Doctrine_Entity::STATE_DIRTY:
case Doctrine_Record::STATE_PROXY: case Doctrine_Entity::STATE_PROXY:
$this->_update($record); $this->_update($record);
break; break;
case Doctrine_Record::STATE_CLEAN: case Doctrine_Entity::STATE_CLEAN:
case Doctrine_Record::STATE_TCLEAN: case Doctrine_Entity::STATE_TCLEAN:
// do nothing // do nothing
break; break;
} }
@ -549,10 +551,10 @@ class Doctrine_Mapper
/** /**
* saves the given record * saves the given record
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return void * @return void
*/ */
public function saveSingleRecord(Doctrine_Record $record) public function saveSingleRecord(Doctrine_Entity $record)
{ {
$this->_insertOrUpdate($record); $this->_insertOrUpdate($record);
} }
@ -562,9 +564,9 @@ class Doctrine_Mapper
* saves all related records to $record * saves all related records to $record
* *
* @throws PDOException if something went wrong at database level * @throws PDOException if something went wrong at database level
* @param Doctrine_Record $record * @param Doctrine_Entity $record
*/ */
protected function _saveRelated(Doctrine_Record $record) protected function _saveRelated(Doctrine_Entity $record)
{ {
$saveLater = array(); $saveLater = array();
foreach ($record->getReferences() as $k => $v) { foreach ($record->getReferences() as $k => $v) {
@ -580,7 +582,7 @@ class Doctrine_Mapper
$obj = $record->get($rel->getAlias()); $obj = $record->get($rel->getAlias());
// Protection against infinite function recursion before attempting to save // Protection against infinite function recursion before attempting to save
if ($obj instanceof Doctrine_Record && $obj->isModified()) { if ($obj instanceof Doctrine_Entity && $obj->isModified()) {
$obj->save($this->_conn); $obj->save($this->_conn);
/** Can this be removed? /** Can this be removed?
@ -609,10 +611,10 @@ class Doctrine_Mapper
* save new associations to 4 and 5 * save new associations to 4 and 5
* *
* @throws Doctrine_Connection_Exception if something went wrong at database level * @throws Doctrine_Connection_Exception if something went wrong at database level
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return void * @return void
*/ */
public function saveAssociations(Doctrine_Record $record) public function saveAssociations(Doctrine_Entity $record)
{ {
foreach ($record->getReferences() as $relationName => $relatedObject) { foreach ($record->getReferences() as $relationName => $relatedObject) {
if ($relatedObject === Doctrine_Null::$INSTANCE) { if ($relatedObject === Doctrine_Null::$INSTANCE) {
@ -650,11 +652,11 @@ class Doctrine_Mapper
/** /**
* Updates an entity. * Updates an entity.
* *
* @param Doctrine_Record $record record to be updated * @param Doctrine_Entity $record record to be updated
* @return boolean whether or not the update was successful * @return boolean whether or not the update was successful
* @todo Move to Doctrine_Table (which will become Doctrine_Mapper). * @todo Move to Doctrine_Table (which will become Doctrine_Mapper).
*/ */
protected function _update(Doctrine_Record $record) protected function _update(Doctrine_Entity $record)
{ {
$record->preUpdate(); $record->preUpdate();
$this->notifyEntityListeners($record, 'preUpdate', Doctrine_Event::RECORD_UPDATE); $this->notifyEntityListeners($record, 'preUpdate', Doctrine_Event::RECORD_UPDATE);
@ -671,10 +673,10 @@ class Doctrine_Mapper
/** /**
* Inserts an entity. * Inserts an entity.
* *
* @param Doctrine_Record $record record to be inserted * @param Doctrine_Entity $record record to be inserted
* @return boolean * @return boolean
*/ */
protected function _insert(Doctrine_Record $record) protected function _insert(Doctrine_Entity $record)
{ {
$record->preInsert(); $record->preInsert();
$this->notifyEntityListeners($record, 'preInsert', Doctrine_Event::RECORD_INSERT); $this->notifyEntityListeners($record, 'preInsert', Doctrine_Event::RECORD_INSERT);
@ -696,7 +698,7 @@ class Doctrine_Mapper
* @return boolean true on success, false on failure * @return boolean true on success, false on failure
* @throws Doctrine_Mapper_Exception * @throws Doctrine_Mapper_Exception
*/ */
public function delete(Doctrine_Record $record, Doctrine_Connection $conn = null) public function delete(Doctrine_Entity $record, Doctrine_Connection $conn = null)
{ {
if ( ! $record->exists()) { if ( ! $record->exists()) {
return false; return false;
@ -717,7 +719,7 @@ class Doctrine_Mapper
$table = $this->_classMetadata; $table = $this->_classMetadata;
$state = $record->state(); $state = $record->state();
$record->state(Doctrine_Record::STATE_LOCKED); $record->state(Doctrine_Entity::STATE_LOCKED);
$this->_mappingStrategy->doDelete($record); $this->_mappingStrategy->doDelete($record);

View File

@ -36,7 +36,7 @@ class Doctrine_Mapper_DefaultStrategy extends Doctrine_Mapper_Strategy
/** /**
* Deletes an entity. * Deletes an entity.
*/ */
public function doDelete(Doctrine_Record $record) public function doDelete(Doctrine_Entity $record)
{ {
$conn = $this->_mapper->getConnection(); $conn = $this->_mapper->getConnection();
$metadata = $this->_mapper->getClassMetadata(); $metadata = $this->_mapper->getClassMetadata();
@ -44,11 +44,11 @@ class Doctrine_Mapper_DefaultStrategy extends Doctrine_Mapper_Strategy
$conn->beginInternalTransaction(); $conn->beginInternalTransaction();
$this->_deleteComposites($record); $this->_deleteComposites($record);
$record->state(Doctrine_Record::STATE_TDIRTY); $record->state(Doctrine_Entity::STATE_TDIRTY);
$identifier = $this->_convertFieldToColumnNames($record->identifier(), $metadata); $identifier = $this->_convertFieldToColumnNames($record->identifier(), $metadata);
$this->_deleteRow($metadata->getTableName(), $identifier); $this->_deleteRow($metadata->getTableName(), $identifier);
$record->state(Doctrine_Record::STATE_TCLEAN); $record->state(Doctrine_Entity::STATE_TCLEAN);
$this->_mapper->removeRecord($record); $this->_mapper->removeRecord($record);
$conn->commit(); $conn->commit();
@ -61,9 +61,9 @@ class Doctrine_Mapper_DefaultStrategy extends Doctrine_Mapper_Strategy
/** /**
* Inserts a single entity into the database, without any related entities. * Inserts a single entity into the database, without any related entities.
* *
* @param Doctrine_Record $record The entity to insert. * @param Doctrine_Entity $record The entity to insert.
*/ */
public function doInsert(Doctrine_Record $record) public function doInsert(Doctrine_Entity $record)
{ {
$conn = $this->_mapper->getConnection(); $conn = $this->_mapper->getConnection();
@ -108,7 +108,7 @@ class Doctrine_Mapper_DefaultStrategy extends Doctrine_Mapper_Strategy
/** /**
* Updates an entity. * Updates an entity.
*/ */
public function doUpdate(Doctrine_Record $record) public function doUpdate(Doctrine_Entity $record)
{ {
$conn = $this->_mapper->getConnection(); $conn = $this->_mapper->getConnection();
$classMetadata = $this->_mapper->getClassMetadata(); $classMetadata = $this->_mapper->getClassMetadata();

View File

@ -38,10 +38,10 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
/** /**
* Inserts an entity that is part of a Class Table Inheritance hierarchy. * Inserts an entity that is part of a Class Table Inheritance hierarchy.
* *
* @param Doctrine_Record $record record to be inserted * @param Doctrine_Entity $record record to be inserted
* @return boolean * @return boolean
*/ */
public function doInsert(Doctrine_Record $record) public function doInsert(Doctrine_Entity $record)
{ {
$class = $this->_mapper->getClassMetadata(); $class = $this->_mapper->getClassMetadata();
$conn = $this->_mapper->getConnection(); $conn = $this->_mapper->getConnection();
@ -92,11 +92,11 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
/** /**
* Updates an entity that is part of a Class Table Inheritance hierarchy. * Updates an entity that is part of a Class Table Inheritance hierarchy.
* *
* @param Doctrine_Record $record record to be updated * @param Doctrine_Entity $record record to be updated
* @return boolean whether or not the update was successful * @return boolean whether or not the update was successful
* @todo Move to Doctrine_Table (which will become Doctrine_Mapper). * @todo Move to Doctrine_Table (which will become Doctrine_Mapper).
*/ */
public function doUpdate(Doctrine_Record $record) public function doUpdate(Doctrine_Entity $record)
{ {
$conn = $this->_mapper->getConnection(); $conn = $this->_mapper->getConnection();
$classMetadata = $this->_mapper->getClassMetadata(); $classMetadata = $this->_mapper->getClassMetadata();
@ -107,7 +107,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
array_unshift($classes, $component); array_unshift($classes, $component);
foreach ($record as $field => $value) { foreach ($record as $field => $value) {
if ($value instanceof Doctrine_Record) { if ($value instanceof Doctrine_Entity) {
if ( ! $value->exists()) { if ( ! $value->exists()) {
$value->save(); $value->save();
} }
@ -130,7 +130,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
* Deletes an entity that is part of a Class Table Inheritance hierarchy. * Deletes an entity that is part of a Class Table Inheritance hierarchy.
* *
*/ */
public function doDelete(Doctrine_Record $record) public function doDelete(Doctrine_Entity $record)
{ {
$conn = $this->_mapper->getConnection(); $conn = $this->_mapper->getConnection();
try { try {
@ -138,7 +138,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
$conn->beginInternalTransaction(); $conn->beginInternalTransaction();
$this->_deleteComposites($record); $this->_deleteComposites($record);
$record->state(Doctrine_Record::STATE_TDIRTY); $record->state(Doctrine_Entity::STATE_TDIRTY);
$identifier = $this->_convertFieldToColumnNames($record->identifier(), $class); $identifier = $this->_convertFieldToColumnNames($record->identifier(), $class);
@ -149,7 +149,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
$this->_deleteRow($parentClass->getTableName(), $identifier); $this->_deleteRow($parentClass->getTableName(), $identifier);
} }
$record->state(Doctrine_Record::STATE_TCLEAN); $record->state(Doctrine_Entity::STATE_TCLEAN);
$this->_mapper->removeRecord($record); $this->_mapper->removeRecord($record);
$conn->commit(); $conn->commit();
@ -286,7 +286,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
* *
* @return array * @return array
*/ */
protected function _groupFieldsByDefiningClass(Doctrine_Record $record) protected function _groupFieldsByDefiningClass(Doctrine_Entity $record)
{ {
$conn = $this->_mapper->getConnection(); $conn = $this->_mapper->getConnection();
$classMetadata = $this->_mapper->getClassMetadata(); $classMetadata = $this->_mapper->getClassMetadata();

View File

@ -67,14 +67,14 @@ abstract class Doctrine_Mapper_Strategy
* @throws PDOException if something went wrong at database level * @throws PDOException if something went wrong at database level
* @return void * @return void
*/ */
protected function _deleteComposites(Doctrine_Record $record) protected function _deleteComposites(Doctrine_Entity $record)
{ {
$classMetadata = $this->_mapper->getClassMetadata(); $classMetadata = $this->_mapper->getClassMetadata();
foreach ($classMetadata->getRelations() as $fk) { foreach ($classMetadata->getRelations() as $fk) {
if ($fk->isComposite()) { if ($fk->isComposite()) {
$obj = $record->get($fk->getAlias()); $obj = $record->get($fk->getAlias());
if ($obj instanceof Doctrine_Record && if ($obj instanceof Doctrine_Entity &&
$obj->state() != Doctrine_Record::STATE_LOCKED) { $obj->state() != Doctrine_Entity::STATE_LOCKED) {
$obj->delete($this->_mapper->getConnection()); $obj->delete($this->_mapper->getConnection());
} }
} }
@ -116,9 +116,9 @@ abstract class Doctrine_Mapper_Strategy
return $this->_mapper->getClassMetadata(); return $this->_mapper->getClassMetadata();
} }
abstract public function doDelete(Doctrine_Record $record); abstract public function doDelete(Doctrine_Entity $record);
abstract public function doInsert(Doctrine_Record $record); abstract public function doInsert(Doctrine_Entity $record);
abstract public function doUpdate(Doctrine_Record $record); abstract public function doUpdate(Doctrine_Entity $record);
/** /**
* Inserts a row into a table. * Inserts a row into a table.

View File

@ -33,7 +33,7 @@
class Doctrine_Node implements IteratorAggregate class Doctrine_Node implements IteratorAggregate
{ {
/** /**
* @param object $record reference to associated Doctrine_Record instance * @param object $record reference to associated Doctrine_Entity instance
*/ */
protected $record; protected $record;
@ -62,10 +62,10 @@ class Doctrine_Node implements IteratorAggregate
/** /**
* contructor, creates node with reference to record and any options * contructor, creates node with reference to record and any options
* *
* @param object $record instance of Doctrine_Record * @param object $record instance of Doctrine_Entity
* @param array $options options * @param array $options options
*/ */
public function __construct(Doctrine_Record $record, $options) public function __construct(Doctrine_Entity $record, $options)
{ {
$this->record = $record; $this->record = $record;
$this->options = $options; $this->options = $options;
@ -90,12 +90,12 @@ class Doctrine_Node implements IteratorAggregate
/** /**
* factory method to return node instance based upon chosen implementation * factory method to return node instance based upon chosen implementation
* *
* @param object $record instance of Doctrine_Record * @param object $record instance of Doctrine_Entity
* @param string $impName implementation (NestedSet, AdjacencyList, MaterializedPath) * @param string $impName implementation (NestedSet, AdjacencyList, MaterializedPath)
* @param array $options options * @param array $options options
* @return object $options instance of Doctrine_Node * @return object $options instance of Doctrine_Node
*/ */
public static function factory(Doctrine_Record $record, $implName, $options = array()) public static function factory(Doctrine_Entity $record, $implName, $options = array())
{ {
$class = 'Doctrine_Node_' . $implName; $class = 'Doctrine_Node_' . $implName;
@ -109,9 +109,9 @@ class Doctrine_Node implements IteratorAggregate
/** /**
* setter for record attribute * setter for record attribute
* *
* @param object $record instance of Doctrine_Record * @param object $record instance of Doctrine_Entity
*/ */
public function setRecord(Doctrine_Record $record) public function setRecord(Doctrine_Entity $record)
{ {
$this->record = $record; $this->record = $record;
} }
@ -119,7 +119,7 @@ class Doctrine_Node implements IteratorAggregate
/** /**
* getter for record attribute * getter for record attribute
* *
* @return object instance of Doctrine_Record * @return object instance of Doctrine_Entity
*/ */
public function getRecord() public function getRecord()
{ {

View File

@ -63,42 +63,42 @@ interface Doctrine_Node_Interface {
/** /**
* gets record of prev sibling or empty record * gets record of prev sibling or empty record
* *
* @return object Doctrine_Record * @return object Doctrine_Entity
*/ */
public function getPrevSibling(); public function getPrevSibling();
/** /**
* gets record of next sibling or empty record * gets record of next sibling or empty record
* *
* @return object Doctrine_Record * @return object Doctrine_Entity
*/ */
public function getNextSibling(); public function getNextSibling();
/** /**
* gets siblings for node * gets siblings for node
* *
* @return array array of sibling Doctrine_Record objects * @return array array of sibling Doctrine_Entity objects
*/ */
public function getSiblings($includeNode = false); public function getSiblings($includeNode = false);
/** /**
* gets record of first child or empty record * gets record of first child or empty record
* *
* @return object Doctrine_Record * @return object Doctrine_Entity
*/ */
public function getFirstChild(); public function getFirstChild();
/** /**
* gets record of last child or empty record * gets record of last child or empty record
* *
* @return object Doctrine_Record * @return object Doctrine_Entity
*/ */
public function getLastChild(); public function getLastChild();
/** /**
* gets children for node (direct descendants only) * gets children for node (direct descendants only)
* *
* @return array array of sibling Doctrine_Record objects * @return array array of sibling Doctrine_Entity objects
*/ */
public function getChildren(); public function getChildren();
@ -112,7 +112,7 @@ interface Doctrine_Node_Interface {
/** /**
* gets record of parent or empty record * gets record of parent or empty record
* *
* @return object Doctrine_Record * @return object Doctrine_Entity
*/ */
public function getParent(); public function getParent();
@ -158,65 +158,65 @@ interface Doctrine_Node_Interface {
* *
* @return bool * @return bool
*/ */
public function insertAsParentOf(Doctrine_Record $dest); public function insertAsParentOf(Doctrine_Entity $dest);
/** /**
* inserts node as previous sibling of dest record * inserts node as previous sibling of dest record
* *
* @return bool * @return bool
*/ */
public function insertAsPrevSiblingOf(Doctrine_Record $dest); public function insertAsPrevSiblingOf(Doctrine_Entity $dest);
/** /**
* inserts node as next sibling of dest record * inserts node as next sibling of dest record
* *
* @return bool * @return bool
*/ */
public function insertAsNextSiblingOf(Doctrine_Record $dest); public function insertAsNextSiblingOf(Doctrine_Entity $dest);
/** /**
* inserts node as first child of dest record * inserts node as first child of dest record
* *
* @return bool * @return bool
*/ */
public function insertAsFirstChildOf(Doctrine_Record $dest); public function insertAsFirstChildOf(Doctrine_Entity $dest);
/** /**
* inserts node as first child of dest record * inserts node as first child of dest record
* *
* @return bool * @return bool
*/ */
public function insertAsLastChildOf(Doctrine_Record $dest); public function insertAsLastChildOf(Doctrine_Entity $dest);
/** /**
* moves node as prev sibling of dest record * moves node as prev sibling of dest record
* *
*/ */
public function moveAsPrevSiblingOf(Doctrine_Record $dest); public function moveAsPrevSiblingOf(Doctrine_Entity $dest);
/** /**
* moves node as next sibling of dest record * moves node as next sibling of dest record
* *
*/ */
public function moveAsNextSiblingOf(Doctrine_Record $dest); public function moveAsNextSiblingOf(Doctrine_Entity $dest);
/** /**
* moves node as first child of dest record * moves node as first child of dest record
* *
*/ */
public function moveAsFirstChildOf(Doctrine_Record $dest); public function moveAsFirstChildOf(Doctrine_Entity $dest);
/** /**
* moves node as last child of dest record * moves node as last child of dest record
* *
*/ */
public function moveAsLastChildOf(Doctrine_Record $dest); public function moveAsLastChildOf(Doctrine_Entity $dest);
/** /**
* adds node as last child of record * adds node as last child of record
* *
*/ */
public function addChild(Doctrine_Record $record); public function addChild(Doctrine_Entity $record);
/** /**
* determines if node is leaf * determines if node is leaf
@ -237,21 +237,21 @@ interface Doctrine_Node_Interface {
* *
* @return bool * @return bool
*/ */
public function isEqualTo(Doctrine_Record $subj); public function isEqualTo(Doctrine_Entity $subj);
/** /**
* determines if node is child of subject node * determines if node is child of subject node
* *
* @return bool * @return bool
*/ */
public function isDescendantOf(Doctrine_Record $subj); public function isDescendantOf(Doctrine_Entity $subj);
/** /**
* determines if node is child of or sibling to subject node * determines if node is child of or sibling to subject node
* *
* @return bool * @return bool
*/ */
public function isDescendantOfOrEqualTo(Doctrine_Record $subj); public function isDescendantOfOrEqualTo(Doctrine_Entity $subj);
/** /**
* determines if node is valid * determines if node is valid

View File

@ -76,7 +76,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
/** /**
* gets record of prev sibling or empty record * gets record of prev sibling or empty record
* *
* @return object Doctrine_Record * @return object Doctrine_Entity
*/ */
public function getPrevSibling() public function getPrevSibling()
{ {
@ -102,7 +102,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
/** /**
* gets record of next sibling or empty record * gets record of next sibling or empty record
* *
* @return object Doctrine_Record * @return object Doctrine_Entity
*/ */
public function getNextSibling() public function getNextSibling()
{ {
@ -128,7 +128,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
/** /**
* gets siblings for node * gets siblings for node
* *
* @return array array of sibling Doctrine_Record objects * @return array array of sibling Doctrine_Entity objects
*/ */
public function getSiblings($includeNode = false) public function getSiblings($includeNode = false)
{ {
@ -148,7 +148,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
/** /**
* gets record of first child or empty record * gets record of first child or empty record
* *
* @return object Doctrine_Record * @return object Doctrine_Entity
*/ */
public function getFirstChild() public function getFirstChild()
{ {
@ -174,7 +174,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
/** /**
* gets record of last child or empty record * gets record of last child or empty record
* *
* @return object Doctrine_Record * @return object Doctrine_Entity
*/ */
public function getLastChild() public function getLastChild()
{ {
@ -243,7 +243,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
/** /**
* gets record of parent or empty record * gets record of parent or empty record
* *
* @return object Doctrine_Record * @return object Doctrine_Entity
*/ */
public function getParent() public function getParent()
{ {
@ -340,7 +340,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* @return bool * @return bool
* @todo Wrap in transaction * @todo Wrap in transaction
*/ */
public function insertAsParentOf(Doctrine_Record $dest) public function insertAsParentOf(Doctrine_Entity $dest)
{ {
// cannot insert a node that has already has a place within the tree // cannot insert a node that has already has a place within the tree
if ($this->isValidNode()) { if ($this->isValidNode()) {
@ -382,7 +382,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* @return bool * @return bool
* @todo Wrap in transaction * @todo Wrap in transaction
*/ */
public function insertAsPrevSiblingOf(Doctrine_Record $dest) public function insertAsPrevSiblingOf(Doctrine_Entity $dest)
{ {
// cannot insert a node that has already has a place within the tree // cannot insert a node that has already has a place within the tree
if ($this->isValidNode()) if ($this->isValidNode())
@ -408,7 +408,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* @return bool * @return bool
* @todo Wrap in transaction * @todo Wrap in transaction
*/ */
public function insertAsNextSiblingOf(Doctrine_Record $dest) public function insertAsNextSiblingOf(Doctrine_Entity $dest)
{ {
// cannot insert a node that has already has a place within the tree // cannot insert a node that has already has a place within the tree
if ($this->isValidNode()) if ($this->isValidNode())
@ -434,7 +434,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* @return bool * @return bool
* @todo Wrap in transaction * @todo Wrap in transaction
*/ */
public function insertAsFirstChildOf(Doctrine_Record $dest) public function insertAsFirstChildOf(Doctrine_Entity $dest)
{ {
// cannot insert a node that has already has a place within the tree // cannot insert a node that has already has a place within the tree
if ($this->isValidNode()) if ($this->isValidNode())
@ -460,7 +460,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* @return bool * @return bool
* @todo Wrap in transaction * @todo Wrap in transaction
*/ */
public function insertAsLastChildOf(Doctrine_Record $dest) public function insertAsLastChildOf(Doctrine_Entity $dest)
{ {
// cannot insert a node that has already has a place within the tree // cannot insert a node that has already has a place within the tree
if ($this->isValidNode()) if ($this->isValidNode())
@ -484,12 +484,12 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* Accomplishes moving of nodes between different trees. * Accomplishes moving of nodes between different trees.
* Used by the move* methods if the root values of the two nodes are different. * Used by the move* methods if the root values of the two nodes are different.
* *
* @param Doctrine_Record $dest * @param Doctrine_Entity $dest
* @param unknown_type $newLeftValue * @param unknown_type $newLeftValue
* @param unknown_type $moveType * @param unknown_type $moveType
* @todo Better exception handling/wrapping * @todo Better exception handling/wrapping
*/ */
private function _moveBetweenTrees(Doctrine_Record $dest, $newLeftValue, $moveType) private function _moveBetweenTrees(Doctrine_Entity $dest, $newLeftValue, $moveType)
{ {
$conn = $this->record->getTable()->getConnection(); $conn = $this->record->getTable()->getConnection();
@ -571,7 +571,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* moves node as prev sibling of dest record * moves node as prev sibling of dest record
* *
*/ */
public function moveAsPrevSiblingOf(Doctrine_Record $dest) public function moveAsPrevSiblingOf(Doctrine_Entity $dest)
{ {
if ($dest->getNode()->getRootValue() != $this->getRootValue()) { if ($dest->getNode()->getRootValue() != $this->getRootValue()) {
// Move between trees // Move between trees
@ -588,7 +588,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* moves node as next sibling of dest record * moves node as next sibling of dest record
* *
*/ */
public function moveAsNextSiblingOf(Doctrine_Record $dest) public function moveAsNextSiblingOf(Doctrine_Entity $dest)
{ {
if ($dest->getNode()->getRootValue() != $this->getRootValue()) { if ($dest->getNode()->getRootValue() != $this->getRootValue()) {
// Move between trees // Move between trees
@ -605,7 +605,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* moves node as first child of dest record * moves node as first child of dest record
* *
*/ */
public function moveAsFirstChildOf(Doctrine_Record $dest) public function moveAsFirstChildOf(Doctrine_Entity $dest)
{ {
if ($dest->getNode()->getRootValue() != $this->getRootValue()) { if ($dest->getNode()->getRootValue() != $this->getRootValue()) {
// Move between trees // Move between trees
@ -622,7 +622,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* moves node as last child of dest record * moves node as last child of dest record
* *
*/ */
public function moveAsLastChildOf(Doctrine_Record $dest) public function moveAsLastChildOf(Doctrine_Entity $dest)
{ {
if ($dest->getNode()->getRootValue() != $this->getRootValue()) { if ($dest->getNode()->getRootValue() != $this->getRootValue()) {
// Move between trees // Move between trees
@ -695,7 +695,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* adds node as last child of record * adds node as last child of record
* *
*/ */
public function addChild(Doctrine_Record $record) public function addChild(Doctrine_Entity $record)
{ {
$record->getNode()->insertAsLastChildOf($this->getRecord()); $record->getNode()->insertAsLastChildOf($this->getRecord());
} }
@ -725,7 +725,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* *
* @return bool * @return bool
*/ */
public function isEqualTo(Doctrine_Record $subj) public function isEqualTo(Doctrine_Entity $subj)
{ {
return (($this->getLeftValue() == $subj->getNode()->getLeftValue()) && return (($this->getLeftValue() == $subj->getNode()->getLeftValue()) &&
($this->getRightValue() == $subj->getNode()->getRightValue()) && ($this->getRightValue() == $subj->getNode()->getRightValue()) &&
@ -738,7 +738,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* *
* @return bool * @return bool
*/ */
public function isDescendantOf(Doctrine_Record $subj) public function isDescendantOf(Doctrine_Entity $subj)
{ {
return (($this->getLeftValue() > $subj->getNode()->getLeftValue()) && return (($this->getLeftValue() > $subj->getNode()->getLeftValue()) &&
($this->getRightValue() < $subj->getNode()->getRightValue()) && ($this->getRightValue() < $subj->getNode()->getRightValue()) &&
@ -750,7 +750,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
* *
* @return bool * @return bool
*/ */
public function isDescendantOfOrEqualTo(Doctrine_Record $subj) public function isDescendantOfOrEqualTo(Doctrine_Entity $subj)
{ {
return (($this->getLeftValue() >= $subj->getNode()->getLeftValue()) && return (($this->getLeftValue() >= $subj->getNode()->getLeftValue()) &&
($this->getRightValue() <= $subj->getNode()->getRightValue()) && ($this->getRightValue() <= $subj->getNode()->getRightValue()) &&
@ -766,7 +766,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
{ {
if ($record === null) { if ($record === null) {
return ($this->getRightValue() > $this->getLeftValue()); return ($this->getRightValue() > $this->getLeftValue());
} else if ( $record instanceof Doctrine_Record ) { } else if ( $record instanceof Doctrine_Entity ) {
return ($record->getNode()->getRightValue() > $record->getNode()->getLeftValue()); return ($record->getNode()->getRightValue() > $record->getNode()->getLeftValue());
} else { } else {
return false; return false;

View File

@ -119,7 +119,7 @@ class Doctrine_Node_NestedSet_PreOrderIterator implements Iterator
/** /**
* returns the current record * returns the current record
* *
* @return Doctrine_Record * @return Doctrine_Entity
*/ */
public function current() public function current()
{ {

View File

@ -1797,7 +1797,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
* unseralize * unseralize
* this method is automatically called everytime a Doctrine_Hydrate object is unserialized * this method is automatically called everytime a Doctrine_Hydrate object is unserialized
* *
* @param string $serialized Doctrine_Record as serialized string * @param string $serialized Doctrine_Entity as serialized string
* @return void * @return void
*/ */
public function unserialize($serialized) public function unserialize($serialized)

View File

@ -249,7 +249,7 @@ abstract class Doctrine_Query_Abstract
$connection = Doctrine_Manager::getInstance()->getCurrentConnection(); $connection = Doctrine_Manager::getInstance()->getCurrentConnection();
} }
if ($hydrator === null) { if ($hydrator === null) {
$hydrator = new Doctrine_Hydrator(); $hydrator = new Doctrine_Hydrator($connection);
} }
$this->_conn = $connection; $this->_conn = $connection;
$this->_hydrator = $hydrator; $this->_hydrator = $hydrator;
@ -988,9 +988,9 @@ abstract class Doctrine_Query_Abstract
if ($cached === false) { if ($cached === false) {
// cache miss // cache miss
$stmt = $this->_execute($params); $stmt = $this->_execute($params);
$this->_hydrator->setQueryComponents($this->_queryComponents); $result = $this->_hydrator->hydrateResultSet(
$result = $this->_hydrator->hydrateResultSet($stmt, $this->_tableAliasMap, $this->_createParserResult($stmt, $this->_queryComponents,
Doctrine::HYDRATE_ARRAY); $this->_tableAliasMap, Doctrine::HYDRATE_ARRAY));
$cached = $this->getCachedForm($result); $cached = $this->getCachedForm($result);
$cacheDriver->save($hash, $cached, $this->_resultCacheTTL); $cacheDriver->save($hash, $cached, $this->_resultCacheTTL);
@ -1005,11 +1005,32 @@ abstract class Doctrine_Query_Abstract
return $stmt; return $stmt;
} }
$this->_hydrator->setQueryComponents($this->_queryComponents); return $this->_hydrator->hydrateResultSet(
return $this->_hydrator->hydrateResultSet($stmt, $this->_tableAliasMap, $hydrationMode); $this->_createParserResult($stmt, $this->_queryComponents,
$this->_tableAliasMap, $hydrationMode));
} }
} }
/**
* Creates a parser result object.
*
* @param unknown_type $stmt
* @param unknown_type $queryComponents
* @param unknown_type $tableToClassAliasMap
* @param unknown_type $hydrationMode
* @return unknown
*/
private function _createParserResult($stmt, $queryComponents, $tableToClassAliasMap,
$hydrationMode)
{
$parserResult = new Doctrine_Query_ParserResultDummy();
$parserResult->setDatabaseStatement($stmt);
$parserResult->setHydrationMode($hydrationMode);
$parserResult->setQueryComponents($queryComponents);
$parserResult->setTableToClassAliasMap($tableToClassAliasMap);
return $parserResult;
}
/** /**
* Constructs the query from the cached form. * Constructs the query from the cached form.
* *

View File

@ -0,0 +1,75 @@
<?php
/**
* This class is just an intermediate implementation for refactoring purposes
* and will be replaced by the ParserResult class of the new DQL parser branch.
*
*/
class Doctrine_Query_ParserResultDummy
{
private $_isMixedQuery;
private $_dbStatement;
private $_isIdentityQuery;
private $_hydrationMode;
private $_tableToClassAliasMap;
private $_queryComponents;
public function isMixedQuery()
{
return $this->_isMixedQuery;
}
public function isIdentityQuery()
{
return $this->_isIdentityQuery;
}
public function setMixedQuery($bool)
{
$this->_isMixedQuery = (bool) $bool;
}
public function getDatabaseStatement()
{
return $this->_dbStatement;
}
public function setDatabaseStatement($stmt)
{
$this->_dbStatement = $stmt;
}
public function getHydrationMode()
{
return $this->_hydrationMode;
}
public function setHydrationMode($hydrationMode)
{
$this->_hydrationMode = $hydrationMode;
}
public function getTableToClassAliasMap()
{
return $this->_tableToClassAliasMap;
}
public function setTableToClassAliasMap(array $map)
{
$this->_tableToClassAliasMap = $map;
}
public function setQueryComponents(array $queryComponents)
{
$this->_queryComponents = $queryComponents;
}
public function getQueryComponents()
{
return $this->_queryComponents;
}
}
?>

View File

@ -20,7 +20,7 @@
*/ */
/** /**
* Doctrine_Record_Filter * Doctrine_Entity_Filter
* Filters the record getters and setters * Filters the record getters and setters
* *
* @package Doctrine * @package Doctrine
@ -46,17 +46,17 @@ abstract class Doctrine_Record_Filter
/** /**
* filterSet * filterSet
* defines an implementation for filtering the set() method of Doctrine_Record * defines an implementation for filtering the set() method of Doctrine_Entity
* *
* @param mixed $name name of the property or related component * @param mixed $name name of the property or related component
*/ */
abstract public function filterSet(Doctrine_Record $record, $name, $value); abstract public function filterSet(Doctrine_Entity $record, $name, $value);
/** /**
* filterGet * filterGet
* defines an implementation for filtering the get() method of Doctrine_Record * defines an implementation for filtering the get() method of Doctrine_Entity
* *
* @param mixed $name name of the property or related component * @param mixed $name name of the property or related component
*/ */
abstract public function filterGet(Doctrine_Record $record, $name); abstract public function filterGet(Doctrine_Entity $record, $name);
} }

View File

@ -48,11 +48,11 @@ class Doctrine_Record_Filter_Compound extends Doctrine_Record_Filter
/** /**
* filterSet * filterSet
* defines an implementation for filtering the set() method of Doctrine_Record * defines an implementation for filtering the set() method of Doctrine_Entity
* *
* @param mixed $name name of the property or related component * @param mixed $name name of the property or related component
*/ */
public function filterSet(Doctrine_Record $record, $name, $value) public function filterSet(Doctrine_Entity $record, $name, $value)
{ {
foreach ($this->_aliases as $alias) { foreach ($this->_aliases as $alias) {
if ( ! $record->exists()) { if ( ! $record->exists()) {
@ -76,11 +76,11 @@ class Doctrine_Record_Filter_Compound extends Doctrine_Record_Filter
/** /**
* filterGet * filterGet
* defines an implementation for filtering the get() method of Doctrine_Record * defines an implementation for filtering the get() method of Doctrine_Entity
* *
* @param mixed $name name of the property or related component * @param mixed $name name of the property or related component
*/ */
public function filterGet(Doctrine_Record $record, $name) public function filterGet(Doctrine_Entity $record, $name)
{ {
foreach ($this->_aliases as $alias) { foreach ($this->_aliases as $alias) {
if ( ! $record->exists()) { if ( ! $record->exists()) {

View File

@ -35,22 +35,22 @@ class Doctrine_Record_Filter_Standard extends Doctrine_Record_Filter
{ {
/** /**
* filterSet * filterSet
* defines an implementation for filtering the set() method of Doctrine_Record * defines an implementation for filtering the set() method of Doctrine_Entity
* *
* @param mixed $name name of the property or related component * @param mixed $name name of the property or related component
*/ */
public function filterSet(Doctrine_Record $record, $name, $value) public function filterSet(Doctrine_Entity $record, $name, $value)
{ {
throw new Doctrine_Record_Exception(sprintf('Unknown record property / related component "%s" on "%s"', $name, get_class($record))); throw new Doctrine_Record_Exception(sprintf('Unknown record property / related component "%s" on "%s"', $name, get_class($record)));
} }
/** /**
* filterGet * filterGet
* defines an implementation for filtering the get() method of Doctrine_Record * defines an implementation for filtering the get() method of Doctrine_Entity
* *
* @param mixed $name name of the property or related component * @param mixed $name name of the property or related component
*/ */
public function filterGet(Doctrine_Record $record, $name) public function filterGet(Doctrine_Entity $record, $name)
{ {
throw new Doctrine_Record_Exception(sprintf('Unknown record property / related component "%s" on "%s"', $name, get_class($record))); throw new Doctrine_Record_Exception(sprintf('Unknown record property / related component "%s" on "%s"', $name, get_class($record)));
} }

View File

@ -33,7 +33,7 @@
class Doctrine_Record_Iterator extends ArrayIterator class Doctrine_Record_Iterator extends ArrayIterator
{ {
/** /**
* @var Doctrine_Record $record * @var Doctrine_Entity $record
*/ */
private $record; private $record;
@ -45,9 +45,9 @@ class Doctrine_Record_Iterator extends ArrayIterator
/** /**
* constructor * constructor
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
*/ */
public function __construct(Doctrine_Record $record) public function __construct(Doctrine_Entity $record)
{ {
$this->record = $record; $this->record = $record;
parent::__construct($record->getData()); parent::__construct($record->getData());

View File

@ -354,10 +354,10 @@ abstract class Doctrine_Relation implements ArrayAccess
* *
* fetches a component related to given record * fetches a component related to given record
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return Doctrine_Record|Doctrine_Collection * @return Doctrine_Entity|Doctrine_Collection
*/ */
abstract public function fetchRelatedFor(Doctrine_Record $record); abstract public function fetchRelatedFor(Doctrine_Entity $record);
/** /**
* __toString * __toString

View File

@ -89,10 +89,10 @@ class Doctrine_Relation_Association extends Doctrine_Relation
* *
* fetches a component related to given record * fetches a component related to given record
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return Doctrine_Record|Doctrine_Collection * @return Doctrine_Entity|Doctrine_Collection
*/ */
public function fetchRelatedFor(Doctrine_Record $record) public function fetchRelatedFor(Doctrine_Entity $record)
{ {
// FIXME: composite key support // FIXME: composite key support
$ids = $record->identifier(); $ids = $record->identifier();

View File

@ -74,7 +74,7 @@ class Doctrine_Relation_Association_Self extends Doctrine_Relation_Association
return $dql; return $dql;
} }
public function fetchRelatedFor(Doctrine_Record $record) public function fetchRelatedFor(Doctrine_Entity $record)
{ {
// FIXME: composite key support // FIXME: composite key support
$ids = $record->identifier(); $ids = $record->identifier();

View File

@ -38,10 +38,10 @@ class Doctrine_Relation_ForeignKey extends Doctrine_Relation
* *
* fetches a component related to given record * fetches a component related to given record
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return Doctrine_Record|Doctrine_Collection * @return Doctrine_Entity|Doctrine_Collection
*/ */
public function fetchRelatedFor(Doctrine_Record $record) public function fetchRelatedFor(Doctrine_Entity $record)
{ {
$id = array(); $id = array();
$localTable = $record->getTable(); $localTable = $record->getTable();

View File

@ -38,10 +38,10 @@ class Doctrine_Relation_LocalKey extends Doctrine_Relation
* *
* fetches a component related to given record * fetches a component related to given record
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return Doctrine_Record|Doctrine_Collection * @return Doctrine_Entity|Doctrine_Collection
*/ */
public function fetchRelatedFor(Doctrine_Record $record) public function fetchRelatedFor(Doctrine_Entity $record)
{ {
$localFieldName = $record->getTable()->getFieldName($this->definition['local']); $localFieldName = $record->getTable()->getFieldName($this->definition['local']);
$id = $record->get($localFieldName); $id = $record->get($localFieldName);

View File

@ -74,7 +74,7 @@ class Doctrine_Relation_Nest extends Doctrine_Relation_Association
return $dql; return $dql;
} }
public function fetchRelatedFor(Doctrine_Record $record) public function fetchRelatedFor(Doctrine_Entity $record)
{ {
// FIXME: composite key support // FIXME: composite key support
$ids = $record->identifier(); $ids = $record->identifier();

View File

@ -96,7 +96,7 @@ class Doctrine_Search extends Doctrine_Record_Generator
* updateIndex * updateIndex
* updates the index * updates the index
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return integer * @return integer
*/ */
public function updateIndex(array $data) public function updateIndex(array $data)

View File

@ -33,7 +33,7 @@
class Doctrine_Template class Doctrine_Template
{ {
/** /**
* @param Doctrine_Record $_invoker the record that invoked the last delegated call * @param Doctrine_Entity $_invoker the record that invoked the last delegated call
*/ */
protected $_invoker; protected $_invoker;
@ -66,10 +66,10 @@ class Doctrine_Template
* *
* sets the last used invoker * sets the last used invoker
* *
* @param Doctrine_Record $invoker the record that invoked the last delegated call * @param Doctrine_Entity $invoker the record that invoked the last delegated call
* @return Doctrine_Template this object * @return Doctrine_Template this object
*/ */
public function setInvoker(Doctrine_Record $invoker) public function setInvoker(Doctrine_Entity $invoker)
{ {
$this->_invoker = $invoker; $this->_invoker = $invoker;
} }
@ -78,7 +78,7 @@ class Doctrine_Template
* setInvoker * setInvoker
* returns the last used invoker * returns the last used invoker
* *
* @return Doctrine_Record the record that invoked the last delegated call * @return Doctrine_Entity the record that invoked the last delegated call
*/ */
public function getInvoker() public function getInvoker()
{ {

View File

@ -92,7 +92,7 @@ class Doctrine_Template_Geographical extends Doctrine_Template
return $query; return $query;
} }
public function getDistance(Doctrine_Record $record, $kilometers = false) public function getDistance(Doctrine_Entity $record, $kilometers = false)
{ {
$query = $this->getDistanceQuery($kilometers); $query = $this->getDistanceQuery($kilometers);

View File

@ -129,12 +129,12 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
* addInvalid * addInvalid
* adds record into invalid records list * adds record into invalid records list
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return boolean false if record already existed in invalid records list, * @return boolean false if record already existed in invalid records list,
* otherwise true * otherwise true
* @todo package:orm * @todo package:orm
*/ */
public function addInvalid(Doctrine_Record $record) public function addInvalid(Doctrine_Entity $record)
{ {
if (in_array($record, $this->invalid, true)) { if (in_array($record, $this->invalid, true)) {
return false; return false;

View File

@ -35,14 +35,14 @@ interface Doctrine_Tree_Interface {
/** /**
* creates root node from given record or from a new record * creates root node from given record or from a new record
* *
* @param object $record instance of Doctrine_Record * @param object $record instance of Doctrine_Entity
*/ */
public function createRoot(Doctrine_Record $record = null); public function createRoot(Doctrine_Entity $record = null);
/** /**
* returns root node * returns root node
* *
* @return object $record instance of Doctrine_Record * @return object $record instance of Doctrine_Entity
*/ */
public function findRoot($root_id = 1); public function findRoot($root_id = 1);

View File

@ -71,9 +71,9 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
/** /**
* creates root node from given record or from a new record * creates root node from given record or from a new record
* *
* @param object $record instance of Doctrine_Record * @param object $record instance of Doctrine_Entity
*/ */
public function createRoot(Doctrine_Record $record = null) public function createRoot(Doctrine_Entity $record = null)
{ {
if ( ! $record) { if ( ! $record) {
$record = $this->table->create(); $record = $this->table->create();
@ -96,7 +96,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
/** /**
* returns root node * returns root node
* *
* @return object $record instance of Doctrine_Record * @return object $record instance of Doctrine_Entity
* @deprecated Use fetchRoot() * @deprecated Use fetchRoot()
*/ */
public function findRoot($rootId = 1) public function findRoot($rootId = 1)
@ -178,7 +178,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
public function fetchBranch($pk, $options = array()) public function fetchBranch($pk, $options = array())
{ {
$record = $this->table->find($pk); $record = $this->table->find($pk);
if ( ! ($record instanceof Doctrine_Record) || !$record->exists()) { if ( ! ($record instanceof Doctrine_Entity) || !$record->exists()) {
// TODO: if record doesn't exist, throw exception or similar? // TODO: if record doesn't exist, throw exception or similar?
return false; return false;
} }

View File

@ -65,10 +65,10 @@ class Doctrine_Validator
* validates a given record and saves possible errors * validates a given record and saves possible errors
* in Doctrine_Validator::$stack * in Doctrine_Validator::$stack
* *
* @param Doctrine_Record $record * @param Doctrine_Entity $record
* @return void * @return void
*/ */
public function validateRecord(Doctrine_Record $record) public function validateRecord(Doctrine_Entity $record)
{ {
$classMetadata = $record->getTable(); $classMetadata = $record->getTable();
$columns = $record->getTable()->getColumns(); $columns = $record->getTable()->getColumns();
@ -83,7 +83,7 @@ class Doctrine_Validator
foreach ($fields as $fieldName => $value) { foreach ($fields as $fieldName => $value) {
if ($value === Doctrine_Null::$INSTANCE) { if ($value === Doctrine_Null::$INSTANCE) {
$value = null; $value = null;
} else if ($value instanceof Doctrine_Record) { } else if ($value instanceof Doctrine_Entity) {
$ids = $value->identifier(); $ids = $value->identifier();
$value = count($ids) > 0 ? array_pop($ids) : null; $value = count($ids) > 0 ? array_pop($ids) : null;
} }

View File

@ -56,7 +56,7 @@ class Doctrine_Validator_Unique
// unique value already exists in the database IF the record in the database is the same // unique value already exists in the database IF the record in the database is the same
// as the one that is validated here. // as the one that is validated here.
$state = $this->invoker->state(); $state = $this->invoker->state();
if ( ! ($state == Doctrine_Record::STATE_TDIRTY || $state == Doctrine_Record::STATE_TCLEAN)) { if ( ! ($state == Doctrine_Entity::STATE_TDIRTY || $state == Doctrine_Entity::STATE_TCLEAN)) {
foreach ((array) $table->getIdentifier() as $pk) { foreach ((array) $table->getIdentifier() as $pk) {
$sql .= " AND {$pk} != ?"; $sql .= " AND {$pk} != ?";
$values[] = $this->invoker->$pk; $values[] = $this->invoker->$pk;

View File

@ -146,7 +146,7 @@ class Doctrine_View
/** /**
* execute * execute
* executes the view * executes the view
* returns a collection of Doctrine_Record objects * returns a collection of Doctrine_Entity objects
* *
* @return Doctrine_Collection * @return Doctrine_Collection
*/ */

View File

@ -4,9 +4,12 @@ require_once 'lib/mocks/Doctrine_HydratorMockStatement.php';
class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
{ {
private $_em;
protected function setUp() protected function setUp()
{ {
parent::setUp(); parent::setUp();
$this->_em = $this->sharedFixture['connection'];
} }
/** Getter for the hydration mode dataProvider */ /** Getter for the hydration mode dataProvider */
@ -18,13 +21,26 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
); );
} }
/** Helper method */
private function _createParserResult($stmt, $queryComponents, $tableToClassAliasMap,
$hydrationMode, $isMixedQuery = false)
{
$parserResult = new Doctrine_Query_ParserResultDummy();
$parserResult->setDatabaseStatement($stmt);
$parserResult->setHydrationMode($hydrationMode);
$parserResult->setQueryComponents($queryComponents);
$parserResult->setTableToClassAliasMap($tableToClassAliasMap);
$parserResult->setMixedQuery($isMixedQuery);
return $parserResult;
}
/** /**
* Select u.id, u.name from CmsUser u * Select u.id, u.name from CmsUser u
* *
* @dataProvider hydrationModeProvider * @dataProvider hydrationModeProvider
*/ */
public function testNewHydrationSimpleEntityQuery($hydrationMode) public function testNewHydrationSimpleEntityQuery($hydrationMode)
{ {
// Faked query components // Faked query components
$queryComponents = array( $queryComponents = array(
'u' => array( 'u' => array(
@ -55,10 +71,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$stmt = new Doctrine_HydratorMockStatement($resultSet); $stmt = new Doctrine_HydratorMockStatement($resultSet);
$hydrator = new Doctrine_HydratorNew(); $hydrator = new Doctrine_HydratorNew($this->_em);
$hydrator->setQueryComponents($queryComponents);
$result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode); $result = $hydrator->hydrateResultSet($this->_createParserResult(
$stmt, $queryComponents, $tableAliasMap, $hydrationMode));
$this->assertEquals(2, count($result)); $this->assertEquals(2, count($result));
$this->assertEquals(1, $result[0]['id']); $this->assertEquals(1, $result[0]['id']);
@ -68,8 +84,8 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
if ($hydrationMode == Doctrine::HYDRATE_RECORD) { if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
$this->assertTrue($result instanceof Doctrine_Collection); $this->assertTrue($result instanceof Doctrine_Collection);
$this->assertTrue($result[0] instanceof Doctrine_Record); $this->assertTrue($result[0] instanceof Doctrine_Entity);
$this->assertTrue($result[1] instanceof Doctrine_Record); $this->assertTrue($result[1] instanceof Doctrine_Entity);
} else { } else {
$this->assertTrue(is_array($result)); $this->assertTrue(is_array($result));
} }
@ -135,12 +151,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
); );
$stmt = new Doctrine_HydratorMockStatement($resultSet); $stmt = new Doctrine_HydratorMockStatement($resultSet);
$hydrator = new Doctrine_HydratorNew(); $hydrator = new Doctrine_HydratorNew($this->_em);
$hydrator->setQueryComponents($queryComponents);
$hydrator->setResultMixed(true); $result = $hydrator->hydrateResultSet($this->_createParserResult(
$stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
$result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
//var_dump($result); //var_dump($result);
$this->assertEquals(2, count($result)); $this->assertEquals(2, count($result));
@ -161,11 +175,11 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this->assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']); $this->assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']);
if ($hydrationMode == Doctrine::HYDRATE_RECORD) { if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
$this->assertTrue($result[0][0] instanceof Doctrine_Record); $this->assertTrue($result[0][0] instanceof Doctrine_Entity);
$this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection); $this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection);
$this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Record); $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Entity);
$this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Record); $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Entity);
$this->assertTrue($result[1][0] instanceof Doctrine_Record); $this->assertTrue($result[1][0] instanceof Doctrine_Entity);
$this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection); $this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection);
} }
} }
@ -223,12 +237,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$stmt = new Doctrine_HydratorMockStatement($resultSet); $stmt = new Doctrine_HydratorMockStatement($resultSet);
$hydrator = new Doctrine_HydratorNew(); $hydrator = new Doctrine_HydratorNew($this->_em);
$hydrator->setQueryComponents($queryComponents);
$hydrator->setResultMixed(true); $result = $hydrator->hydrateResultSet($this->_createParserResult(
$stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
$result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
//var_dump($result); //var_dump($result);
$this->assertEquals(2, count($result)); $this->assertEquals(2, count($result));
@ -242,8 +254,8 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this->assertEquals(1, $result[1]['numPhones']); $this->assertEquals(1, $result[1]['numPhones']);
if ($hydrationMode == Doctrine::HYDRATE_RECORD) { if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
$this->assertTrue($result[0][0] instanceof Doctrine_Record); $this->assertTrue($result[0][0] instanceof Doctrine_Entity);
$this->assertTrue($result[1][0] instanceof Doctrine_Record); $this->assertTrue($result[1][0] instanceof Doctrine_Entity);
} }
} }
@ -308,13 +320,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$stmt = new Doctrine_HydratorMockStatement($resultSet); $stmt = new Doctrine_HydratorMockStatement($resultSet);
$hydrator = new Doctrine_HydratorNew(); $hydrator = new Doctrine_HydratorNew($this->_em);
$hydrator->setQueryComponents($queryComponents);
// give the hydrator an artificial hint $result = $hydrator->hydrateResultSet($this->_createParserResult(
$hydrator->setResultMixed(true); $stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
$result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
//var_dump($result); //var_dump($result);
} }
@ -340,8 +349,8 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this->assertEquals('JWAGE', $result[1]['nameUpper']); $this->assertEquals('JWAGE', $result[1]['nameUpper']);
if ($hydrationMode == Doctrine::HYDRATE_RECORD) { if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
$this->assertTrue($result[0]['1'] instanceof Doctrine_Record); $this->assertTrue($result[0]['1'] instanceof Doctrine_Entity);
$this->assertTrue($result[1]['2'] instanceof Doctrine_Record); $this->assertTrue($result[1]['2'] instanceof Doctrine_Entity);
$this->assertTrue($result[0]['1']['phonenumbers'] instanceof Doctrine_Collection); $this->assertTrue($result[0]['1']['phonenumbers'] instanceof Doctrine_Collection);
$this->assertEquals(2, count($result[0]['1']['phonenumbers'])); $this->assertEquals(2, count($result[0]['1']['phonenumbers']));
} }
@ -450,12 +459,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
); );
$stmt = new Doctrine_HydratorMockStatement($resultSet); $stmt = new Doctrine_HydratorMockStatement($resultSet);
$hydrator = new Doctrine_HydratorNew(); $hydrator = new Doctrine_HydratorNew($this->_em);
$hydrator->setQueryComponents($queryComponents);
$hydrator->setResultMixed(true); $result = $hydrator->hydrateResultSet($this->_createParserResult(
$stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
$result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
//var_dump($result); //var_dump($result);
} }
@ -484,18 +491,18 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this->assertEquals('PHP6', $result[1][0]['articles'][1]['topic']); $this->assertEquals('PHP6', $result[1][0]['articles'][1]['topic']);
if ($hydrationMode == Doctrine::HYDRATE_RECORD) { if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
$this->assertTrue($result[0][0] instanceof Doctrine_Record); $this->assertTrue($result[0][0] instanceof Doctrine_Entity);
$this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection); $this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection);
$this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Record); $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Entity);
$this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Record); $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Entity);
$this->assertTrue($result[0][0]['articles'] instanceof Doctrine_Collection); $this->assertTrue($result[0][0]['articles'] instanceof Doctrine_Collection);
$this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Record); $this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Entity);
$this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Record); $this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Entity);
$this->assertTrue($result[1][0] instanceof Doctrine_Record); $this->assertTrue($result[1][0] instanceof Doctrine_Entity);
$this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection); $this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection);
$this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Record); $this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Entity);
$this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Record); $this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Entity);
$this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Record); $this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Entity);
} }
} }
@ -625,12 +632,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
); );
$stmt = new Doctrine_HydratorMockStatement($resultSet); $stmt = new Doctrine_HydratorMockStatement($resultSet);
$hydrator = new Doctrine_HydratorNew(); $hydrator = new Doctrine_HydratorNew($this->_em);
$hydrator->setQueryComponents($queryComponents);
$hydrator->setResultMixed(true); $result = $hydrator->hydrateResultSet($this->_createParserResult(
$stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
$result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
//var_dump($result); //var_dump($result);
} }
@ -667,23 +672,23 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this->assertFalse(isset($result[1][0]['articles'][1]['comments'])); $this->assertFalse(isset($result[1][0]['articles'][1]['comments']));
if ($hydrationMode == Doctrine::HYDRATE_RECORD) { if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
$this->assertTrue($result[0][0] instanceof Doctrine_Record); $this->assertTrue($result[0][0] instanceof Doctrine_Entity);
$this->assertTrue($result[1][0] instanceof Doctrine_Record); $this->assertTrue($result[1][0] instanceof Doctrine_Entity);
// phonenumbers // phonenumbers
$this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection); $this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection);
$this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Record); $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Entity);
$this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Record); $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Entity);
$this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection); $this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection);
$this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Record); $this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Entity);
// articles // articles
$this->assertTrue($result[0][0]['articles'] instanceof Doctrine_Collection); $this->assertTrue($result[0][0]['articles'] instanceof Doctrine_Collection);
$this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Record); $this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Entity);
$this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Record); $this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Entity);
$this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Record); $this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Entity);
$this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Record); $this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Entity);
// article comments // article comments
$this->assertTrue($result[0][0]['articles'][0]['comments'] instanceof Doctrine_Collection); $this->assertTrue($result[0][0]['articles'][0]['comments'] instanceof Doctrine_Collection);
$this->assertTrue($result[0][0]['articles'][0]['comments'][0] instanceof Doctrine_Record); $this->assertTrue($result[0][0]['articles'][0]['comments'][0] instanceof Doctrine_Entity);
} }
} }
@ -772,12 +777,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
); );
$stmt = new Doctrine_HydratorMockStatement($resultSet); $stmt = new Doctrine_HydratorMockStatement($resultSet);
$hydrator = new Doctrine_HydratorNew(); $hydrator = new Doctrine_HydratorNew($this->_em);
$hydrator->setQueryComponents($queryComponents);
//$hydrator->setResultMixed(true); $result = $hydrator->hydrateResultSet($this->_createParserResult(
$stmt, $queryComponents, $tableAliasMap, $hydrationMode));
$result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
//var_dump($result); //var_dump($result);
} }
@ -794,9 +797,9 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this->assertTrue(is_array($result[1])); $this->assertTrue(is_array($result[1]));
} else { } else {
$this->assertTrue($result instanceof Doctrine_Collection); $this->assertTrue($result instanceof Doctrine_Collection);
$this->assertTrue($result[0] instanceof Doctrine_Record); $this->assertTrue($result[0] instanceof Doctrine_Entity);
$this->assertTrue($result[1] instanceof Doctrine_Record); $this->assertTrue($result[1] instanceof Doctrine_Entity);
} }
} }
} }

View File

@ -31,7 +31,7 @@ class Orm_UnitOfWorkTestCase extends Doctrine_OrmTestCase
{ {
$this->_user->username = 'romanb'; $this->_user->username = 'romanb';
$this->_user->id = 1; $this->_user->id = 1;
$this->assertEquals(Doctrine_Record::STATE_TDIRTY, $this->_user->state()); $this->assertEquals(Doctrine_Entity::STATE_TDIRTY, $this->_user->state());
$this->assertFalse($this->_unitOfWork->contains($this->_user)); $this->assertFalse($this->_unitOfWork->contains($this->_user));
$this->_unitOfWork->registerDirty($this->_user); $this->_unitOfWork->registerDirty($this->_user);
$this->assertTrue($this->_unitOfWork->isRegisteredDirty($this->_user)); $this->assertTrue($this->_unitOfWork->isRegisteredDirty($this->_user));

View File

@ -1,5 +1,5 @@
<?php <?php
class CmsArticle extends Doctrine_Record class CmsArticle extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {

View File

@ -1,5 +1,5 @@
<?php <?php
class CmsComment extends Doctrine_Record class CmsComment extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {

View File

@ -1,5 +1,5 @@
<?php <?php
class CmsPhonenumber extends Doctrine_Record class CmsPhonenumber extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {

View File

@ -1,5 +1,5 @@
<?php <?php
class CmsUser extends Doctrine_Record class CmsUser extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {

View File

@ -1,5 +1,5 @@
<?php <?php
class ForumBoard extends Doctrine_Record { class ForumBoard extends Doctrine_Entity {
public static function initMetadata($class) { public static function initMetadata($class) {
$class->mapColumn('position', 'integer'); $class->mapColumn('position', 'integer');
$class->mapColumn('category_id', 'integer'); $class->mapColumn('category_id', 'integer');

View File

@ -1,5 +1,5 @@
<?php <?php
class ForumCategory extends Doctrine_Record { class ForumCategory extends Doctrine_Entity {
public static function initMetadata($class) { public static function initMetadata($class) {
$class->mapColumn('position', 'integer'); $class->mapColumn('position', 'integer');
$class->mapColumn('name', 'string', 255); $class->mapColumn('name', 'string', 255);

View File

@ -1,6 +1,6 @@
<?php <?php
class ForumUser extends Doctrine_Record class ForumUser extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {

View File

@ -11,7 +11,7 @@ class Doctrine_Cache_FileTestCase extends Doctrine_UnitTestCase {
$this->assertTrue($this->cache->exists(4)); $this->assertTrue($this->cache->exists(4));
$record = $this->cache->fetch(4); $record = $this->cache->fetch(4);
$this->assertTrue($record instanceof Doctrine_Record); $this->assertTrue($record instanceof Doctrine_Entity);
$this->assertTrue($record->obtainIdentifier() == $this->old->obtainIdentifier()); $this->assertTrue($record->obtainIdentifier() == $this->old->obtainIdentifier());
$this->assertTrue($this->cache->getTable() == $this->objTable); $this->assertTrue($this->cache->getTable() == $this->objTable);

View File

@ -21,7 +21,7 @@ class Doctrine_Cache_SqliteTestCase extends Doctrine_UnitTestCase {
$this->assertTrue($this->cache->store($this->objTable->find(4))); $this->assertTrue($this->cache->store($this->objTable->find(4)));
$record = $this->cache->fetch(4); $record = $this->cache->fetch(4);
$this->assertTrue($record instanceof Doctrine_Record); $this->assertTrue($record instanceof Doctrine_Entity);
foreach($this->old as $name => $value) { foreach($this->old as $name => $value) {
$this->assertEqual($record->get($name), $value); $this->assertEqual($record->get($name), $value);
@ -36,7 +36,7 @@ class Doctrine_Cache_SqliteTestCase extends Doctrine_UnitTestCase {
$array = $this->cache->fetchMultiple(array(5,6)); $array = $this->cache->fetchMultiple(array(5,6));
$this->assertEqual(gettype($array), "array"); $this->assertEqual(gettype($array), "array");
$this->assertEqual(count($array), 1); $this->assertEqual(count($array), 1);
$this->assertTrue($array[0] instanceof Doctrine_Record); $this->assertTrue($array[0] instanceof Doctrine_Entity);
} }
public function testDeleteMultiple() { public function testDeleteMultiple() {
$this->assertEqual($this->cache->deleteMultiple(array()),0); $this->assertEqual($this->cache->deleteMultiple(array()),0);
@ -52,7 +52,7 @@ class Doctrine_Cache_SqliteTestCase extends Doctrine_UnitTestCase {
} }
public function testDelete() { public function testDelete() {
$this->cache->store($this->objTable->find(5)); $this->cache->store($this->objTable->find(5));
$this->assertTrue($this->cache->fetch(5) instanceof Doctrine_Record); $this->assertTrue($this->cache->fetch(5) instanceof Doctrine_Entity);
$this->assertEqual($this->cache->delete(5),true); $this->assertEqual($this->cache->delete(5),true);
$this->assertFalse($this->cache->fetch(5)); $this->assertFalse($this->cache->fetch(5));

View File

@ -225,7 +225,7 @@ class Doctrine_ClassTableInheritance_TestCase extends Doctrine_UnitTestCase
$this->conn->addListener(new Doctrine_EventListener()); $this->conn->addListener(new Doctrine_EventListener());
} }
} }
class CTITestParent1 extends Doctrine_Record class CTITestParent1 extends Doctrine_Entity
{ {
public function setTableDefinition() public function setTableDefinition()
{ {
@ -265,7 +265,7 @@ class CTITest extends CTITestParent4
} }
} }
class CTITestOneToManyRelated extends Doctrine_Record class CTITestOneToManyRelated extends Doctrine_Entity
{ {
public function setTableDefinition() public function setTableDefinition()
{ {

View File

@ -8,16 +8,16 @@ class Doctrine_Collection_Offset_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual(count($users), 5); $this->assertEqual(count($users), 5);
$users[5]; $users[5];
$this->assertEqual($users[5]->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[5]->getState(), Doctrine_Entity::STATE_CLEAN);
$users[5]; $users[5];
$this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3); $this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3);
$users = $this->connection->query("FROM User-o"); $users = $this->connection->query("FROM User-o");
$this->assertEqual(count($users), 3); $this->assertEqual(count($users), 3);
$this->assertEqual($users[0]->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[0]->getState(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($users[1]->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[1]->getState(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($users[2]->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[2]->getState(), Doctrine_Entity::STATE_CLEAN);
// indexes 0,1,2 in use // indexes 0,1,2 in use
$users[7]; $users[7];
@ -28,15 +28,15 @@ class Doctrine_Collection_Offset_TestCase extends Doctrine_UnitTestCase {
$this->assertTrue($users->contains(6)); $this->assertTrue($users->contains(6));
$this->assertTrue($users->contains(7)); $this->assertTrue($users->contains(7));
$this->assertEqual($users[6]->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[6]->getState(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($users[7]->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[7]->getState(), Doctrine_Entity::STATE_CLEAN);
$users[5]; $users[5];
$this->assertEqual(count($users), 8); $this->assertEqual(count($users), 8);
$this->assertEqual($users[3]->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[3]->getState(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($users[4]->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[4]->getState(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($users[5]->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[5]->getState(), Doctrine_Entity::STATE_CLEAN);
$this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 1); $this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 1);
@ -61,8 +61,8 @@ class Doctrine_Collection_Offset_TestCase extends Doctrine_UnitTestCase {
foreach($coll as $user) { foreach($coll as $user) {
} }
$this->assertEqual($coll->count(), 8); $this->assertEqual($coll->count(), 8);
$this->assertEqual($coll[3]->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($coll[3]->getState(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($coll[6]->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($coll[6]->getState(), Doctrine_Entity::STATE_CLEAN);
$this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3); $this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3);
@ -71,7 +71,7 @@ class Doctrine_Collection_Offset_TestCase extends Doctrine_UnitTestCase {
foreach($coll as $user) { foreach($coll as $user) {
} }
$this->assertEqual($coll->count(), 8); $this->assertEqual($coll->count(), 8);
$this->assertEqual($coll[3]->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($coll[3]->getState(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($coll[6]->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($coll[6]->getState(), Doctrine_Entity::STATE_CLEAN);
} }
} }

View File

@ -251,7 +251,7 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
$this->assertEqual(count($coll), 3); $this->assertEqual(count($coll), 3);
$this->assertEqual($coll[2]->state(), Doctrine_Record::STATE_PROXY); $this->assertEqual($coll[2]->state(), Doctrine_Entity::STATE_PROXY);
@ -287,8 +287,8 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
$this->assertFalse($users->contains(0)); $this->assertFalse($users->contains(0));
$this->assertEqual($users->count(), 8); $this->assertEqual($users->count(), 8);
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_TCLEAN);
$this->assertEqual($users[4]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[4]->state(), Doctrine_Entity::STATE_CLEAN);
} }
public function testFetchCollectionWithNameAsIndex() public function testFetchCollectionWithNameAsIndex()
{ {
@ -299,8 +299,8 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
$this->assertFalse($users->contains(0)); $this->assertFalse($users->contains(0));
$this->assertEqual($users->count(), 8); $this->assertEqual($users->count(), 8);
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_TCLEAN);
$this->assertEqual($users['zYne']->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users['zYne']->state(), Doctrine_Entity::STATE_CLEAN);
} }
public function testFetchMultipleCollections() public function testFetchMultipleCollections()
{ {
@ -317,16 +317,16 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
$this->assertFalse($users->contains(0)); $this->assertFalse($users->contains(0));
$this->assertEqual($users->count(), 8); $this->assertEqual($users->count(), 8);
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_TCLEAN);
$this->assertEqual($users[2]->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($users[2]->state(), Doctrine_Entity::STATE_TCLEAN);
$this->assertEqual($users[3]->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($users[3]->state(), Doctrine_Entity::STATE_TCLEAN);
$this->assertEqual($users[4]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[4]->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($users[4]->name, 'zYne'); $this->assertEqual($users[4]->name, 'zYne');
$this->assertEqual($users[4]->Phonenumber[0]->exists(), false); $this->assertEqual($users[4]->Phonenumber[0]->exists(), false);
$this->assertEqual($users[4]->Phonenumber[0]->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($users[4]->Phonenumber[0]->state(), Doctrine_Entity::STATE_TDIRTY);
$this->assertEqual($users[4]->Phonenumber[1]->exists(), false); $this->assertEqual($users[4]->Phonenumber[1]->exists(), false);
$this->assertEqual($users[4]->Phonenumber[2]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[4]->Phonenumber[2]->state(), Doctrine_Entity::STATE_CLEAN);
} }
} }

View File

@ -153,7 +153,7 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase
{ {
//$user = $this->connection->create('User'); //$user = $this->connection->create('User');
//$this->connection->unitOfWork->delete($user); //$this->connection->unitOfWork->delete($user);
//$this->assertEqual($user->state(),Doctrine_Record::STATE_TCLEAN); //$this->assertEqual($user->state(),Doctrine_Entity::STATE_TCLEAN);
} }
public function testGetTable() public function testGetTable()

View File

@ -34,7 +34,7 @@ class Doctrine_CtiColumnAggregation_TestCase extends Doctrine_UnitTestCase
{ {
} }
abstract class CTICAAbstractBase extends Doctrine_Record abstract class CTICAAbstractBase extends Doctrine_Entity
{ } { }
class CTICATestParent1 extends CTICAAbstractBase class CTICATestParent1 extends CTICAAbstractBase
{ {
@ -85,7 +85,7 @@ class CTICATest2 extends CTICATestParent2
} }
} }
class CTICATestOneToManyRelated extends Doctrine_Record class CTICATestOneToManyRelated extends Doctrine_Entity
{ {
public function setTableDefinition() public function setTableDefinition()
{ {

View File

@ -44,7 +44,7 @@ class Doctrine_CustomPrimaryKey_TestCase extends Doctrine_UnitTestCase
public function testOperations() public function testOperations()
{ {
$c = new CustomPK(); $c = new CustomPK();
$this->assertTrue($c instanceof Doctrine_Record); $this->assertTrue($c instanceof Doctrine_Entity);
$c->name = 'custom pk test'; $c->name = 'custom pk test';
$this->assertEqual($c->identifier(), array()); $this->assertEqual($c->identifier(), array());

View File

@ -42,7 +42,7 @@ class Doctrine_DataType_Boolean_TestCase extends Doctrine_UnitTestCase {
$test->is_working = false; $test->is_working = false;
$this->assertIdentical($test->is_working, false); $this->assertIdentical($test->is_working, false);
$this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($test->state(), Doctrine_Entity::STATE_TDIRTY);
$test->save(); $test->save();
$test->refresh(); $test->refresh();
@ -98,7 +98,7 @@ class Doctrine_DataType_Boolean_TestCase extends Doctrine_UnitTestCase {
$this->is_working = null; $this->is_working = null;
$this->assertIdentical($this->is_working, null); $this->assertIdentical($this->is_working, null);
$this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($test->state(), Doctrine_Entity::STATE_TDIRTY);
$test->save(); $test->save();
$test->refresh(); $test->refresh();
@ -108,7 +108,7 @@ class Doctrine_DataType_Boolean_TestCase extends Doctrine_UnitTestCase {
$this->is_working_notnull = null; $this->is_working_notnull = null;
$this->assertIdentical($this->is_working_notnull, null); $this->assertIdentical($this->is_working_notnull, null);
$this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($test->state(), Doctrine_Entity::STATE_TDIRTY);
$test->save(); $test->save();
$test->refresh(); $test->refresh();

View File

@ -110,7 +110,7 @@ class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($users[0]['Email']['address'], 'zYne@example.com'); $this->assertEqual($users[0]['Email']['address'], 'zYne@example.com');
$this->assertTrue($users[0] instanceof User); $this->assertTrue($users[0] instanceof User);
$this->assertTrue($users instanceof Doctrine_Collection); $this->assertTrue($users instanceof Doctrine_Collection);
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($users[0]->id, 4); $this->assertEqual($users[0]->id, 4);
$this->assertTrue($users[0]['Email'] instanceof Email); $this->assertTrue($users[0]['Email'] instanceof Email);
@ -128,7 +128,7 @@ class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase
$this->assertEqual(count($users), 8); $this->assertEqual(count($users), 8);
$this->assertTrue($users[0] instanceof User); $this->assertTrue($users[0] instanceof User);
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertTrue($users instanceof Doctrine_Collection); $this->assertTrue($users instanceof Doctrine_Collection);
$this->assertTrue($users[0]->Phonenumber instanceof Doctrine_Collection); $this->assertTrue($users[0]->Phonenumber instanceof Doctrine_Collection);
} }
@ -143,7 +143,7 @@ class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase
$this->assertEqual(count($users), 8); $this->assertEqual(count($users), 8);
$this->assertTrue($users[0] instanceof User); $this->assertTrue($users[0] instanceof User);
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($this->conn->count(), $count + 1); $this->assertEqual($this->conn->count(), $count + 1);

View File

@ -101,7 +101,7 @@ class Doctrine_Hydrate_Mock extends Doctrine_Hydrator_Abstract
$this->data = $data; $this->data = $data;
} }
public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null) public function hydrateResultSet($parserResult)
{ {
return true; return true;
} }

View File

@ -183,7 +183,7 @@ class Doctrine_Inheritance_Joined_TestCase extends Doctrine_UnitTestCase
} }
class CTI_User extends Doctrine_Record class CTI_User extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {

View File

@ -63,7 +63,7 @@ class Doctrine_Inheritance_SingleTable_TestCase extends Doctrine_UnitTestCase
} }
class STI_User extends Doctrine_Record class STI_User extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {

View File

@ -66,7 +66,7 @@ class Doctrine_Inheritance_TablePerClass_TestCase extends Doctrine_UnitTestCase
} }
class CCTI_User extends Doctrine_Record class CCTI_User extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {

View File

@ -141,7 +141,7 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
} }
class Metadata_User extends Doctrine_Record class Metadata_User extends Doctrine_Entity
{ {
public static function initMetadata(Doctrine_ClassMetadata $class) public static function initMetadata(Doctrine_ClassMetadata $class)
{ {
@ -195,7 +195,7 @@ class Metadata_SuperManager extends Metadata_Manager
class Metadata_STI_User extends Doctrine_Record class Metadata_STI_User extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {

View File

@ -101,7 +101,7 @@ class Doctrine_PessimisticLocking_TestCase extends Doctrine_UnitTestCase {
* Tests the retrieving of a lock's owner. * Tests the retrieving of a lock's owner.
* This test implicitly tests getLock(). * This test implicitly tests getLock().
* *
* @param Doctrine_Record $lockedRecord * @param Doctrine_Entity $lockedRecord
*/ */
public function testGetLockOwner() { public function testGetLockOwner() {
$entries = $this->connection->query("FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'"); $entries = $this->connection->query("FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'");

View File

@ -59,7 +59,7 @@ class Doctrine_Plugin_TestCase extends Doctrine_UnitTestCase
public function testCreatingNewRecordsInvokesAllPlugins() public function testCreatingNewRecordsInvokesAllPlugins()
{ {
$wiki = new Wiki(); $wiki = new Wiki();
$wiki->state(Doctrine_Record::STATE_TDIRTY); $wiki->state(Doctrine_Entity::STATE_TDIRTY);
$wiki->save(); $wiki->save();
$fi = $wiki->Translation['FI']; $fi = $wiki->Translation['FI'];
@ -86,7 +86,7 @@ class Doctrine_Plugin_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($wiki->Translation['FI']->version, 2); $this->assertEqual($wiki->Translation['FI']->version, 2);
} }
} }
class Wiki extends Doctrine_Record class Wiki extends Doctrine_Entity
{ {
public function setTableDefinition() public function setTableDefinition()
{ {

View File

@ -92,7 +92,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($users->count(), 1); $this->assertEqual($users->count(), 1);
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_TCLEAN);
} }
public function testAggregateValueIsMappedToRecord() public function testAggregateValueIsMappedToRecord()
@ -105,8 +105,8 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($users->count(), 2); $this->assertEqual($users->count(), 2);
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_PROXY); $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_PROXY);
$this->assertEqual($users[1]->state(), Doctrine_Record::STATE_PROXY); $this->assertEqual($users[1]->state(), Doctrine_Entity::STATE_PROXY);
$this->assertEqual($users[0]->count, 2); $this->assertEqual($users[0]->count, 2);
$this->assertEqual($users[1]->count, 2); $this->assertEqual($users[1]->count, 2);
@ -122,8 +122,8 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($users->count(), 2); $this->assertEqual($users->count(), 2);
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_PROXY); $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_PROXY);
$this->assertEqual($users[1]->state(), Doctrine_Record::STATE_PROXY); $this->assertEqual($users[1]->state(), Doctrine_Entity::STATE_PROXY);
$this->assertEqual($users[0]->count, 2); $this->assertEqual($users[0]->count, 2);
$this->assertEqual($users[1]->count, 2); $this->assertEqual($users[1]->count, 2);

View File

@ -293,7 +293,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
$users = $q->execute(); $users = $q->execute();
$this->assertEqual($users[0]->Phonenumber[0]->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($users[0]->Phonenumber[0]->state(), Doctrine_Entity::STATE_TDIRTY);
$this->assertEqual($users[0]->Phonenumber[0]->count, 1); $this->assertEqual($users[0]->Phonenumber[0]->count, 1);
$this->assertEqual($users[1]->Phonenumber[0]->count, 3); $this->assertEqual($users[1]->Phonenumber[0]->count, 3);

View File

@ -84,8 +84,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($coll->count(), 11); $this->assertEqual($coll->count(), 11);
$this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_PROXY); $this->assertEqual($coll[0]->state(), Doctrine_Entity::STATE_PROXY);
$this->assertEqual($coll[3]->state(), Doctrine_Record::STATE_PROXY); $this->assertEqual($coll[3]->state(), Doctrine_Entity::STATE_PROXY);
} }
public function testSmartMapping() public function testSmartMapping()
{ {
@ -101,8 +101,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($coll->count(), 11); $this->assertEqual($coll->count(), 11);
$this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_PROXY); $this->assertEqual($coll[0]->state(), Doctrine_Entity::STATE_PROXY);
$this->assertEqual($coll[3]->state(), Doctrine_Record::STATE_PROXY); $this->assertEqual($coll[3]->state(), Doctrine_Entity::STATE_PROXY);
} }
public function testMultipleComponents() public function testMultipleComponents()

View File

@ -84,7 +84,7 @@ class Doctrine_Record_Filter_TestCase extends Doctrine_UnitTestCase
} }
} }
} }
class CompositeRecord extends Doctrine_Record class CompositeRecord extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {
@ -94,7 +94,7 @@ class CompositeRecord extends Doctrine_Record
$class->unshiftFilter(new Doctrine_Record_Filter_Compound(array('Related'))); $class->unshiftFilter(new Doctrine_Record_Filter_Compound(array('Related')));
} }
} }
class RelatedCompositeRecord extends Doctrine_Record class RelatedCompositeRecord extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {

View File

@ -90,11 +90,11 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($r->something, 'something'); $this->assertEqual($r->something, 'something');
$this->assertEqual($r->deleted, null); $this->assertEqual($r->deleted, null);
$this->assertEqual($r->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($r->state(), Doctrine_Entity::STATE_CLEAN);
try { try {
$r->delete(); $r->delete();
$this->assertEqual($r->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($r->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($r->deleted, true); $this->assertEqual($r->deleted, true);
} catch(Doctrine_Exception $e) { } catch(Doctrine_Exception $e) {
$this->fail(); $this->fail();

View File

@ -4,7 +4,7 @@
* Doctrine_Record_Inheritance_TestCase * Doctrine_Record_Inheritance_TestCase
* *
* This test case demonstrates the use of inheritance involving subclasses of * This test case demonstrates the use of inheritance involving subclasses of
* Doctrine_Record. This type of inheritance is heavily used in sfDoctrine, * Doctrine_Entity. This type of inheritance is heavily used in sfDoctrine,
* and as new inheritance-related features get added to Doctrine it seems to * and as new inheritance-related features get added to Doctrine it seems to
* be an area where subtle breakage can sneak in. * be an area where subtle breakage can sneak in.
* *
@ -49,7 +49,7 @@ class Doctrine_Record_Inheritance_TestCase extends Doctrine_UnitTestCase
// does it have the appropriate parentage? // does it have the appropriate parentage?
$this->assertTrue($record instanceof PluginSymfonyRecord); $this->assertTrue($record instanceof PluginSymfonyRecord);
$this->assertTrue($record instanceof BaseSymfonyRecord); $this->assertTrue($record instanceof BaseSymfonyRecord);
$this->assertTrue($record instanceof Doctrine_Record); $this->assertTrue($record instanceof Doctrine_Entity);
// does it have the expected data? // does it have the expected data?
$this->assertEqual($record['name'], 'Test me'); $this->assertEqual($record['name'], 'Test me');

View File

@ -90,79 +90,79 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
} catch(Doctrine_Record_State_Exception $e) { } catch(Doctrine_Record_State_Exception $e) {
$this->pass(); $this->pass();
} }
$this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
try { try {
$user->state('some unknown state'); $user->state('some unknown state');
$this->fail(); $this->fail();
} catch(Doctrine_Record_State_Exception $e) { } catch(Doctrine_Entity_State_Exception $e) {
$this->pass(); $this->pass();
} }
$this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
} }
public function testAssignDirtyState() public function testAssignDirtyState()
{ {
$user = new User(); $user = new User();
$user->state(Doctrine_Record::STATE_DIRTY); $user->state(Doctrine_Entity::STATE_DIRTY);
$this->assertEqual($user->state(), Doctrine_Record::STATE_DIRTY); $this->assertEqual($user->state(), Doctrine_Entity::STATE_DIRTY);
$user->state('dirty'); $user->state('dirty');
$this->assertEqual($user->state(), Doctrine_Record::STATE_DIRTY); $this->assertEqual($user->state(), Doctrine_Entity::STATE_DIRTY);
} }
public function testAssignCleanState() public function testAssignCleanState()
{ {
$user = new User(); $user = new User();
$user->state(Doctrine_Record::STATE_CLEAN); $user->state(Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($user->state(), Doctrine_Entity::STATE_CLEAN);
$user->state('clean'); $user->state('clean');
$this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($user->state(), Doctrine_Entity::STATE_CLEAN);
} }
public function testAssignTransientCleanState() public function testAssignTransientCleanState()
{ {
$user = new User(); $user = new User();
$user->state(Doctrine_Record::STATE_TCLEAN); $user->state(Doctrine_Entity::STATE_TCLEAN);
$this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
$user->state('tclean'); $user->state('tclean');
$this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
} }
public function testAssignTransientDirtyState() public function testAssignTransientDirtyState()
{ {
$user = new User(); $user = new User();
$user->state(Doctrine_Record::STATE_TDIRTY); $user->state(Doctrine_Entity::STATE_TDIRTY);
$this->assertEqual($user->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($user->state(), Doctrine_Entity::STATE_TDIRTY);
$user->state('tdirty'); $user->state('tdirty');
$this->assertEqual($user->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($user->state(), Doctrine_Entity::STATE_TDIRTY);
} }
public function testAssignProxyState() public function testAssignProxyState()
{ {
$user = new User(); $user = new User();
$user->state(Doctrine_Record::STATE_PROXY); $user->state(Doctrine_Entity::STATE_PROXY);
$this->assertEqual($user->state(), Doctrine_Record::STATE_PROXY); $this->assertEqual($user->state(), Doctrine_Entity::STATE_PROXY);
$user->state('proxy'); $user->state('proxy');
$this->assertEqual($user->state(), Doctrine_Record::STATE_PROXY); $this->assertEqual($user->state(), Doctrine_Entity::STATE_PROXY);
} }
public function testProxiesAreAutomaticallyUpdatedWithFetches() public function testProxiesAreAutomaticallyUpdatedWithFetches()
@ -176,7 +176,7 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
$user = $this->connection->queryOne("SELECT u.name FROM User u WHERE u.name = 'someuser'"); $user = $this->connection->queryOne("SELECT u.name FROM User u WHERE u.name = 'someuser'");
$this->assertEqual($user->state(), Doctrine_Record::STATE_PROXY); $this->assertEqual($user->state(), Doctrine_Entity::STATE_PROXY);
$user2 = $this->connection->queryOne("FROM User u WHERE u.name = 'someuser'"); $user2 = $this->connection->queryOne("FROM User u WHERE u.name = 'someuser'");
@ -208,7 +208,7 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
// to make sure it is saved correctly // to make sure it is saved correctly
$user1 = $this->connection->queryOne("FROM User u WHERE u.name = '" . UNAME . "'"); $user1 = $this->connection->queryOne("FROM User u WHERE u.name = '" . UNAME . "'");
$this->assertEqual($user1->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($user1->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($user1->name,UNAME) ; $this->assertEqual($user1->name,UNAME) ;
$this->assertEqual($user1->password,UPWD1) ; $this->assertEqual($user1->password,UPWD1) ;
$this->assertEqual($user1->loginname,ULNAME) ; $this->assertEqual($user1->loginname,ULNAME) ;
@ -222,7 +222,7 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
$user2 = $this->connection->queryOne("SELECT u.name FROM User u WHERE u.name = '" . UNAME . "'"); $user2 = $this->connection->queryOne("SELECT u.name FROM User u WHERE u.name = '" . UNAME . "'");
// the object should be in state proxy with only 'name' fetched ... // the object should be in state proxy with only 'name' fetched ...
$this->assertEqual($user2->state(), Doctrine_Record::STATE_PROXY); $this->assertEqual($user2->state(), Doctrine_Entity::STATE_PROXY);
$this->assertEqual($user2->name,UNAME) ; $this->assertEqual($user2->name,UNAME) ;
$this->assertEqual($user2->password,null) ; $this->assertEqual($user2->password,null) ;
$this->assertEqual($user2->loginname,null) ; $this->assertEqual($user2->loginname,null) ;
@ -231,7 +231,7 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
$user2->password = UPWD2 ; $user2->password = UPWD2 ;
// now it should be dirty (but may be PDIRTY ... ?) // now it should be dirty (but may be PDIRTY ... ?)
$this->assertEqual($user2->state(),Doctrine_Record::STATE_DIRTY) ; $this->assertEqual($user2->state(),Doctrine_Entity::STATE_DIRTY) ;
$this->assertEqual($user2->name,UNAME) ; $this->assertEqual($user2->name,UNAME) ;
$this->assertEqual($user2->password,UPWD2) ; $this->assertEqual($user2->password,UPWD2) ;
$this->assertEqual($user2->loginname,null) ; $this->assertEqual($user2->loginname,null) ;
@ -240,11 +240,11 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
$user2->save() ; $user2->save() ;
// the logic would suggest the object to go back to PROXY mode (becausse $user2->loginname is null aka not sync with DB) // the logic would suggest the object to go back to PROXY mode (becausse $user2->loginname is null aka not sync with DB)
$boolState = ($user2->loginname == null) && ($user2->state() === Doctrine_Record::STATE_PROXY) ; $boolState = ($user2->loginname == null) && ($user2->state() === Doctrine_Entity::STATE_PROXY) ;
// this one will currently fail // this one will currently fail
$this->assertTrue($boolState) ; $this->assertTrue($boolState) ;
// this will also currently fail (becausse it currently goes back to STATE_CLEAN, which shouldnt be the case) // this will also currently fail (becausse it currently goes back to STATE_CLEAN, which shouldnt be the case)
//$this->assertEqual($user2->state(), Doctrine_Record::STATE_PROXY); //$this->assertEqual($user2->state(), Doctrine_Entity::STATE_PROXY);
$this->assertEqual($user2->name,UNAME) ; $this->assertEqual($user2->name,UNAME) ;
$this->assertEqual($user2->password,UPWD2) ; $this->assertEqual($user2->password,UPWD2) ;
$this->assertEqual($user2->loginname,null) ; $this->assertEqual($user2->loginname,null) ;

View File

@ -55,7 +55,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$account = $user->Account; $account = $user->Account;
$account->amount = 1000; $account->amount = 1000;
$this->assertTrue($account instanceof Account); $this->assertTrue($account instanceof Account);
$this->assertEqual($account->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($account->state(), Doctrine_Entity::STATE_TDIRTY);
$this->assertEqual($account->entity_id->getOid(), $user->getOid()); $this->assertEqual($account->entity_id->getOid(), $user->getOid());
$this->assertEqual($account->amount, 1000); $this->assertEqual($account->amount, 1000);
$this->assertEqual($user->name, "Richard Linklater"); $this->assertEqual($user->name, "Richard Linklater");
@ -67,7 +67,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$account = $user->Account; $account = $user->Account;
$this->assertTrue($account instanceof Account); $this->assertTrue($account instanceof Account);
$this->assertEqual($account->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($account->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($account->entity_id, $user->id); $this->assertEqual($account->entity_id, $user->id);
$this->assertEqual($account->amount, 1000); $this->assertEqual($account->amount, 1000);
$this->assertEqual($user->name, "Richard Linklater"); $this->assertEqual($user->name, "Richard Linklater");
@ -80,7 +80,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($account->getTable()->getColumnNames(), array('id', 'entity_id', 'amount')); $this->assertEqual($account->getTable()->getColumnNames(), array('id', 'entity_id', 'amount'));
$this->connection->unitOfWork->saveAll(); $this->connection->unitOfWork->saveAll();
$this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($user->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertTrue($account instanceof Account); $this->assertTrue($account instanceof Account);
$this->assertEqual($account->getTable()->getColumnNames(), array('id', 'entity_id', 'amount')); $this->assertEqual($account->getTable()->getColumnNames(), array('id', 'entity_id', 'amount'));
@ -90,13 +90,13 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$user = $user->getRepository()->find($user->id); $user = $user->getRepository()->find($user->id);
$this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($user->state(), Doctrine_Entity::STATE_CLEAN);
$account = $user->Account; $account = $user->Account;
$this->assertTrue($account instanceof Account); $this->assertTrue($account instanceof Account);
$this->assertEqual($account->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($account->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($account->getTable()->getColumnNames(), array('id', 'entity_id', 'amount')); $this->assertEqual($account->getTable()->getColumnNames(), array('id', 'entity_id', 'amount'));
$this->assertEqual($account->entity_id, $user->id); $this->assertEqual($account->entity_id, $user->id);
@ -272,23 +272,23 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$this->assertEqual((array)$record->getTable()->getIdentifier(), array("entity1","entity2")); $this->assertEqual((array)$record->getTable()->getIdentifier(), array("entity1","entity2"));
$this->assertEqual($record->getTable()->getIdentifierType(), Doctrine::IDENTIFIER_COMPOSITE); $this->assertEqual($record->getTable()->getIdentifierType(), Doctrine::IDENTIFIER_COMPOSITE);
$this->assertEqual($record->identifier(), array("entity1" => null, "entity2" => null)); $this->assertEqual($record->identifier(), array("entity1" => null, "entity2" => null));
$this->assertEqual($record->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($record->state(), Doctrine_Entity::STATE_TCLEAN);
$record->entity1 = 3; $record->entity1 = 3;
$record->entity2 = 4; $record->entity2 = 4;
$this->assertEqual($record->entity2, 4); $this->assertEqual($record->entity2, 4);
$this->assertEqual($record->entity1, 3); $this->assertEqual($record->entity1, 3);
$this->assertEqual($record->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($record->state(), Doctrine_Entity::STATE_TDIRTY);
$this->assertEqual($record->identifier(), array("entity1" => 3, "entity2" => 4)); $this->assertEqual($record->identifier(), array("entity1" => 3, "entity2" => 4));
$record->save(); $record->save();
$this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($record->entity2, 4); $this->assertEqual($record->entity2, 4);
$this->assertEqual($record->entity1, 3); $this->assertEqual($record->entity1, 3);
$this->assertEqual($record->identifier(), array("entity1" => 3, "entity2" => 4)); $this->assertEqual($record->identifier(), array("entity1" => 3, "entity2" => 4));
$record = $record->getRepository()->find($record->identifier()); $record = $record->getRepository()->find($record->identifier());
$this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($record->entity2, 4); $this->assertEqual($record->entity2, 4);
$this->assertEqual($record->entity1, 3); $this->assertEqual($record->entity1, 3);
@ -296,26 +296,26 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$record->entity2 = 5; $record->entity2 = 5;
$record->entity1 = 2; $record->entity1 = 2;
$this->assertEqual($record->state(), Doctrine_Record::STATE_DIRTY); $this->assertEqual($record->state(), Doctrine_Entity::STATE_DIRTY);
$this->assertEqual($record->entity2, 5); $this->assertEqual($record->entity2, 5);
$this->assertEqual($record->entity1, 2); $this->assertEqual($record->entity1, 2);
$this->assertEqual($record->identifier(), array("entity1" => 3, "entity2" => 4)); $this->assertEqual($record->identifier(), array("entity1" => 3, "entity2" => 4));
$record->save(); $record->save();
$this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($record->entity2, 5); $this->assertEqual($record->entity2, 5);
$this->assertEqual($record->entity1, 2); $this->assertEqual($record->entity1, 2);
$this->assertEqual($record->identifier(), array("entity1" => 2, "entity2" => 5)); $this->assertEqual($record->identifier(), array("entity1" => 2, "entity2" => 5));
$record = $record->getRepository()->find($record->identifier()); $record = $record->getRepository()->find($record->identifier());
$this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($record->entity2, 5); $this->assertEqual($record->entity2, 5);
$this->assertEqual($record->entity1, 2); $this->assertEqual($record->entity1, 2);
$this->assertEqual($record->identifier(), array("entity1" => 2, "entity2" => 5)); $this->assertEqual($record->identifier(), array("entity1" => 2, "entity2" => 5));
$record->refresh(); $record->refresh();
$this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($record->entity2, 5); $this->assertEqual($record->entity2, 5);
$this->assertEqual($record->entity1, 2); $this->assertEqual($record->entity1, 2);
$this->assertEqual($record->identifier(), array("entity1" => 2, "entity2" => 5)); $this->assertEqual($record->identifier(), array("entity1" => 2, "entity2" => 5));
@ -327,9 +327,9 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$coll = $this->connection->query("FROM EntityReference"); $coll = $this->connection->query("FROM EntityReference");
$this->assertTrue($coll[0] instanceof EntityReference); $this->assertTrue($coll[0] instanceof EntityReference);
$this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($coll[0]->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertTrue($coll[1] instanceof EntityReference); $this->assertTrue($coll[1] instanceof EntityReference);
$this->assertEqual($coll[1]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($coll[1]->state(), Doctrine_Entity::STATE_CLEAN);
$coll = $this->connection->query("FROM EntityReference WHERE EntityReference.entity2 = 5"); $coll = $this->connection->query("FROM EntityReference WHERE EntityReference.entity2 = 5");
$this->assertEqual($coll->count(), 1); $this->assertEqual($coll->count(), 1);
@ -351,12 +351,12 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$task = new Task(); $task = new Task();
$this->assertTrue($task instanceof Task); $this->assertTrue($task instanceof Task);
$this->assertEqual($task->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($task->state(), Doctrine_Entity::STATE_TCLEAN);
$this->assertTrue($task->Subtask[0] instanceof Task); $this->assertTrue($task->Subtask[0] instanceof Task);
//$this->assertEqual($task->Subtask[0]->state(), Doctrine_Record::STATE_TDIRTY); //$this->assertEqual($task->Subtask[0]->state(), Doctrine_Entity::STATE_TDIRTY);
$this->assertTrue($task->ResourceAlias[0] instanceof Resource); $this->assertTrue($task->ResourceAlias[0] instanceof Resource);
$this->assertEqual($task->ResourceAlias[0]->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($task->ResourceAlias[0]->state(), Doctrine_Entity::STATE_TCLEAN);
$task->name = "Task 1"; $task->name = "Task 1";
$task->ResourceAlias[0]->name = "Resource 1"; $task->ResourceAlias[0]->name = "Resource 1";
@ -398,13 +398,13 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$table = $this->connection->getClassMetadata("User"); $table = $this->connection->getClassMetadata("User");
$user = new User(); $user = new User();
$this->assertEqual(Doctrine_Lib::getRecordStateAsString($user->state()), Doctrine_Lib::getRecordStateAsString(Doctrine_Record::STATE_TCLEAN)); $this->assertEqual(Doctrine_Lib::getRecordStateAsString($user->state()), Doctrine_Lib::getRecordStateAsString(Doctrine_Entity::STATE_TCLEAN));
$user->name = "John Locke"; $user->name = "John Locke";
$this->assertTrue($user->name,"John Locke"); $this->assertTrue($user->name,"John Locke");
$this->assertTrue($user->state() == Doctrine_Record::STATE_TDIRTY); $this->assertTrue($user->state() == Doctrine_Entity::STATE_TDIRTY);
$user->save(); $user->save();
$this->assertTrue($user->state() == Doctrine_Record::STATE_CLEAN); $this->assertTrue($user->state() == Doctrine_Entity::STATE_CLEAN);
$this->assertTrue($user->name,"John Locke"); $this->assertTrue($user->name,"John Locke");
} }
@ -546,10 +546,10 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$this->assertTrue(is_numeric($user->id) && $user->id > 0); $this->assertTrue(is_numeric($user->id) && $user->id > 0);
$this->assertTrue($user->getModified() == array()); $this->assertTrue($user->getModified() == array());
$this->assertTrue($user->state() == Doctrine_Record::STATE_CLEAN); $this->assertTrue($user->state() == Doctrine_Entity::STATE_CLEAN);
$user->delete(); $user->delete();
$this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
} }
public function testUpdate() public function testUpdate()
@ -570,8 +570,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$user = $this->connection->getRepository("User")->find(4); $user = $this->connection->getRepository("User")->find(4);
$new = $user->copy(); $new = $user->copy();
$this->assertTrue($new instanceof Doctrine_Record); $this->assertTrue($new instanceof Doctrine_Entity);
$this->assertTrue($new->state() == Doctrine_Record::STATE_TDIRTY); $this->assertTrue($new->state() == Doctrine_Entity::STATE_TDIRTY);
$new = $user->copy(); $new = $user->copy();
$new->save(); $new->save();
@ -587,8 +587,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$user = $this->connection->getRepository("User")->find(4); $user = $this->connection->getRepository("User")->find(4);
$new = $user->copy(); $new = $user->copy();
$this->assertTrue($new instanceof Doctrine_Record); $this->assertTrue($new instanceof Doctrine_Entity);
$this->assertTrue($new->state() == Doctrine_Record::STATE_TDIRTY); $this->assertTrue($new->state() == Doctrine_Entity::STATE_TDIRTY);
$new->loginname = 'jackd'; $new->loginname = 'jackd';
@ -702,7 +702,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$this->assertTrue($user->Email instanceof Email); $this->assertTrue($user->Email instanceof Email);
$this->assertEqual($user->Email->id, $user->email_id); $this->assertEqual($user->Email->id, $user->email_id);
$this->assertEqual($user->Email->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($user->Email->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($user->Email->address, "drinker@drinkmore.info"); $this->assertEqual($user->Email->address, "drinker@drinkmore.info");
$id = $user->Email->id; $id = $user->Email->id;
@ -871,7 +871,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
{ {
$user = $this->connection->getRepository("User")->find(4); $user = $this->connection->getRepository("User")->find(4);
$this->assertTrue($user->Email instanceof Doctrine_Record); $this->assertTrue($user->Email instanceof Doctrine_Entity);
$this->assertTrue($user->Phonenumber instanceof Doctrine_Collection); $this->assertTrue($user->Phonenumber instanceof Doctrine_Collection);
$this->assertTrue($user->Group instanceof Doctrine_Collection); $this->assertTrue($user->Group instanceof Doctrine_Collection);

View File

@ -81,7 +81,7 @@ class Doctrine_Relation_Access_TestCase extends Doctrine_UnitTestCase {
public function testOneToOneAggregateRelationFetching() { public function testOneToOneAggregateRelationFetching() {
$coll = $this->connection->query("FROM File_Owner.Data_File WHERE File_Owner.name = 'owner1'"); $coll = $this->connection->query("FROM File_Owner.Data_File WHERE File_Owner.name = 'owner1'");
$this->assertTrue(count($coll) == 1); $this->assertTrue(count($coll) == 1);
$this->assertTrue($coll[0] instanceof Doctrine_Record); $this->assertTrue($coll[0] instanceof Doctrine_Entity);
$this->assertEqual($coll[0]->id, 1); $this->assertEqual($coll[0]->id, 1);
} }

View File

@ -48,8 +48,8 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
$this->assertTrue($e->Entity[0] instanceof Entity); $this->assertTrue($e->Entity[0] instanceof Entity);
$this->assertTrue($e->Entity[1] instanceof Entity); $this->assertTrue($e->Entity[1] instanceof Entity);
$this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($e->Entity[0]->state(), Doctrine_Entity::STATE_TCLEAN);
$this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($e->Entity[1]->state(), Doctrine_Entity::STATE_TCLEAN);
$e->Entity[0]->name = 'Friend 1'; $e->Entity[0]->name = 'Friend 1';
$e->Entity[1]->name = 'Friend 2'; $e->Entity[1]->name = 'Friend 2';
@ -69,8 +69,8 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($e->Entity[1]->Entity[0]->name, 'Friend 2 1'); $this->assertEqual($e->Entity[1]->Entity[0]->name, 'Friend 2 1');
$this->assertEqual($e->Entity[1]->Entity[1]->name, 'Friend 2 2'); $this->assertEqual($e->Entity[1]->Entity[1]->name, 'Friend 2 2');
$this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($e->Entity[0]->state(), Doctrine_Entity::STATE_TDIRTY);
$this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($e->Entity[1]->state(), Doctrine_Entity::STATE_TDIRTY);
$count = count($this->conn); $count = count($this->conn);
@ -83,7 +83,7 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
$this->connection->clear(); $this->connection->clear();
$e = $this->conn->queryOne('FROM Entity e LEFT JOIN e.Entity e2 LEFT JOIN e2.Entity e3 WHERE e.id = 1 ORDER BY e.name, e2.name, e3.name'); $e = $this->conn->queryOne('FROM Entity e LEFT JOIN e.Entity e2 LEFT JOIN e2.Entity e3 WHERE e.id = 1 ORDER BY e.name, e2.name, e3.name');
$this->assertEqual($e->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($e->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertTrue($e->Entity[0] instanceof Entity); $this->assertTrue($e->Entity[0] instanceof Entity);
$this->assertTrue($e->Entity[1] instanceof Entity); $this->assertTrue($e->Entity[1] instanceof Entity);
@ -99,8 +99,8 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($e->Entity[1]->Entity[1]->name, 'Friend 2 1'); $this->assertEqual($e->Entity[1]->Entity[1]->name, 'Friend 2 1');
$this->assertEqual($e->Entity[1]->Entity[2]->name, 'Friend 2 2'); $this->assertEqual($e->Entity[1]->Entity[2]->name, 'Friend 2 2');
$this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($e->Entity[0]->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($e->Entity[1]->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertTrue(is_numeric($e->id)); $this->assertTrue(is_numeric($e->id));
@ -135,12 +135,12 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($e->Entity[1]->Entity[0]->name, "Entity test"); $this->assertEqual($e->Entity[1]->Entity[0]->name, "Entity test");
$this->assertEqual($e->Entity[1]->Entity[1]->name, "Friend 2 1"); $this->assertEqual($e->Entity[1]->Entity[1]->name, "Friend 2 1");
$this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($e->Entity[0]->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($e->Entity[1]->state(), Doctrine_Entity::STATE_CLEAN);
$coll = $this->connection->query("FROM Entity WHERE Entity.name = 'Friend 1'"); $coll = $this->connection->query("FROM Entity WHERE Entity.name = 'Friend 1'");
$this->assertEqual($coll->count(), 1); $this->assertEqual($coll->count(), 1);
$this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($coll[0]->state(), Doctrine_Entity::STATE_CLEAN);
$this->assertEqual($coll[0]->name, "Friend 1"); $this->assertEqual($coll[0]->name, "Friend 1");

View File

@ -149,18 +149,18 @@ class Doctrine_Table_TestCase extends Doctrine_UnitTestCase
public function testCreate() public function testCreate()
{ {
$record = $this->objTable->create(); $record = $this->objTable->create();
$this->assertTrue($record instanceof Doctrine_Record); $this->assertTrue($record instanceof Doctrine_Entity);
$this->assertTrue($record->state() == Doctrine_Record::STATE_TCLEAN); $this->assertTrue($record->state() == Doctrine_Entity::STATE_TCLEAN);
} }
public function testFind() public function testFind()
{ {
$record = $this->objTable->find(4); $record = $this->objTable->find(4);
$this->assertTrue($record instanceof Doctrine_Record); $this->assertTrue($record instanceof Doctrine_Entity);
try { try {
$record = $this->objTable->find('4'); $record = $this->objTable->find('4');
$this->assertTrue($record instanceof Doctrine_Record); $this->assertTrue($record instanceof Doctrine_Entity);
} catch(Exception $e) { } catch(Exception $e) {
$this->assertTrue(false); $this->assertTrue(false);
} }
@ -171,7 +171,7 @@ class Doctrine_Table_TestCase extends Doctrine_UnitTestCase
$this->assertTrue( ! is_object($record)); $this->assertTrue( ! is_object($record));
$this->assertTrue(array_key_exists('id', $record)); $this->assertTrue(array_key_exists('id', $record));
$this->assertTrue(array_key_exists('name', $record)); $this->assertTrue(array_key_exists('name', $record));
$this->assertTrue( ! $record instanceof Doctrine_Record); $this->assertTrue( ! $record instanceof Doctrine_Entity);
} catch(Exception $e) { } catch(Exception $e) {
$this->assertTrue(false); $this->assertTrue(false);
} }
@ -221,7 +221,7 @@ class Doctrine_Table_TestCase extends Doctrine_UnitTestCase
public function testGetProxy() public function testGetProxy()
{ {
$user = $this->objTable->getProxy(4); $user = $this->objTable->getProxy(4);
$this->assertTrue($user instanceof Doctrine_Record); $this->assertTrue($user instanceof Doctrine_Entity);
try { try {
$record = $this->objTable->find(123); $record = $this->objTable->find(123);

View File

@ -107,7 +107,7 @@ class Doctrine_Ticket_438_TestCase extends Doctrine_UnitTestCase
} }
class T438_Student extends Doctrine_Record class T438_Student extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {
@ -119,7 +119,7 @@ class T438_Student extends Doctrine_Record
} }
class T438_Course extends Doctrine_Record class T438_Course extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {
@ -130,7 +130,7 @@ class T438_Course extends Doctrine_Record
} }
} }
class T438_StudentCourse extends Doctrine_Record class T438_StudentCourse extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {

View File

@ -31,7 +31,7 @@
* @version $Revision$ * @version $Revision$
*/ */
class stComment extends Doctrine_Record class stComment extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {

View File

@ -88,7 +88,7 @@ class Doctrine_Ticket_626B_TestCase extends Doctrine_UnitTestCase
} }
class T626B_Student extends Doctrine_Record class T626B_Student extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {
@ -103,7 +103,7 @@ class T626B_Student extends Doctrine_Record
} }
} }
class T626_Group extends Doctrine_Record class T626_Group extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {
@ -117,7 +117,7 @@ class T626_Group extends Doctrine_Record
} }
class T626_Course extends Doctrine_Record class T626_Course extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {
@ -129,7 +129,7 @@ class T626_Course extends Doctrine_Record
} }
} }
class T626B_StudentCourse extends Doctrine_Record class T626B_StudentCourse extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {

View File

@ -62,7 +62,7 @@ class Doctrine_Ticket_626C_TestCase extends Doctrine_UnitTestCase
} }
class T626C_Student1 extends Doctrine_Record class T626C_Student1 extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {
@ -73,7 +73,7 @@ class T626C_Student1 extends Doctrine_Record
} }
} }
class T626C_Student2 extends Doctrine_Record class T626C_Student2 extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
{ {

Some files were not shown because too many files have changed in this diff Show More