1
0
mirror of synced 2025-01-18 22:41:43 +03:00

refactorings

This commit is contained in:
romanb 2008-02-13 10:53:07 +00:00
parent 72316541c4
commit b6a6866b9c
8 changed files with 125 additions and 593 deletions

View File

@ -240,6 +240,7 @@ final class Doctrine
* IMMEDIATE FETCHING
* mode for immediate fetching
* @see self::ATTR_FETCHMODE
* @deprecated???
*/
const FETCHMODE_IMMEDIATE = 0;
@ -249,6 +250,7 @@ final class Doctrine
* mode for batch fetching
*
* @see self::ATTR_FETCHMODE
* @deprecated???
*/
const FETCHMODE_BATCH = 1;
@ -258,6 +260,7 @@ final class Doctrine
* mode for offset fetching
*
* @see self::ATTR_FETCHMODE
* @deprecated???
*/
const FETCHMODE_OFFSET = 3;
@ -267,6 +270,7 @@ final class Doctrine
* mode for lazy offset fetching
*
* @see self::ATTR_FETCHMODE
* @deprecated???
*/
const FETCHMODE_LAZY_OFFSET = 4;
@ -387,6 +391,7 @@ final class Doctrine
*
* mode for optimistic locking
* @see self::ATTR_LOCK
* @deprecated???
*/
const LOCK_OPTIMISTIC = 0;
@ -396,6 +401,7 @@ final class Doctrine
* mode for pessimistic locking
*
* @see self::ATTR_LOCK
* @deprecated???
*/
const LOCK_PESSIMISTIC = 1;

View File

@ -36,6 +36,13 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
*/
protected $_entityName;
/**
* The name of the custom mapper class used for the entity class.
*
* @var string
*/
protected $_customMapperClassName;
/**
*
* @var Doctrine_Connection
@ -49,9 +56,9 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
/**
* The field names of all fields that are part of the identifier/primary key
* of the described class.
* of the described entity class.
*
* @var array
* @var array
*/
protected $_identifier = array();
@ -134,8 +141,9 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
/**
* An array of field names. used to look up field names from column names.
* Keys are column names and values are field names.
* This is the reverse lookup map of $_columnNames.
*
* @var array
* @var array
*/
protected $_fieldNames = array();
@ -161,10 +169,10 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
protected $_tree;
/**
* Cached column count, Doctrine_Record uses this column count in when
* Cached column count, Doctrine_Record uses this column count when
* determining its state.
*
* @var integer
* @var integer
*/
protected $_columnCount;
@ -201,8 +209,8 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
protected $_options = array(
'treeImpl' => null,
'treeOptions' => null,
'subclasses' => array(),
'queryParts' => array(),
'subclasses' => array(),
'parents' => array()
);
@ -1589,7 +1597,32 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
* Registers a custom mapper for the entity class.
*
* @param string $mapperClassName The class name of the custom mapper.
*/
public function setCustomMapperClass($mapperClassName)
{
if ( ! is_subclass_of($mapperClassName, 'Doctrine_Mapper')) {
throw new Doctrine_ClassMetadata_Exception("The custom mapper must be a subclass"
. " of Doctrine_Mapper.");
}
$this->_customMapperClassName = $mapperClassName;
}
/**
* Gets the name of the custom mapper class used for the entity class.
*
* @return string|null The name of the custom mapper class or NULL if the entity
* class does not have a custom mapper class.
*/
public function getCustomMapperClass()
{
return $this->_customMapperClassName;
}
/**
* @todo Thoughts & Implementation.
*/
public function setType($type)
{
@ -1599,7 +1632,9 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
* @todo Implementation.
* @todo Implementation. Immutable entities can not be updated or deleted once
* they are created. This means the entity can only be modified as long as it's
* in transient state (TCLEAN, TDIRTY).
*/
public function isImmutable()
{

View File

@ -52,6 +52,7 @@ Doctrine::autoload('Doctrine_Configurable');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Lukas Smith <smith@pooteeweet.org> (MDB2 library)
* @author Roman Borschel <roman@code-factory.org>
*/
abstract class Doctrine_Connection extends Doctrine_Configurable implements Countable, IteratorAggregate
{
@ -63,16 +64,18 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
protected $dbh;
/**
* The metadata factory is used to retrieve the metadata of classes.
* The metadata factory is used to retrieve the metadata of entity classes.
*
* @var Doctrine_ClassMetadata_Factory
* @todo package:orm
*/
protected $_metadataFactory;
/**
* An array of mapper objects currently maintained by this connection.
*
* @var array
* @var array
* @todo package:orm
*/
protected $_mappers = array();
@ -202,6 +205,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*
* @param Doctrine_Manager $manager the manager object
* @param PDO|Doctrine_Adapter_Interface $adapter database driver
* @todo Remove the dependency on the Manager for DBAL/ORM separation.
*/
public function __construct(Doctrine_Manager $manager, $adapter, $user = null, $pass = null)
{
@ -985,7 +989,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
if ( ! empty($params)) {
$stmt = $this->prepare($query);
$stmt->execute($params);
//echo "<br /><br />" . $query . "<br /><br />";
return $stmt->rowCount();
} else {
$event = new Doctrine_Event($this, Doctrine_Event::CONN_EXEC, $query, $params);
@ -994,7 +997,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
if ( ! $event->skipOperation) {
$count = $this->dbh->exec($query);
//echo "<br /><br />" . $query . "<br /><br />";
$this->_count++;
}
$this->getAttribute(Doctrine::ATTR_LISTENER)->postExec($event);
@ -1042,6 +1044,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*
* @param mixed $name
* @return boolean
* @deprecated
* @todo package:orm
*/
public function hasTable($name)
{
@ -1052,6 +1056,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* Returns the metadata for a class.
*
* @return Doctrine_Metadata
* @deprecated Use getClassMetadata()
* @todo package:orm
*/
public function getMetadata($className)
@ -1080,6 +1085,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* classes.
*
* @param $driver The driver to use.
* @todo package:orm
*/
public function setClassMetadataDriver($driver)
{
@ -1090,35 +1096,35 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* Gets a mapper for the specified domain class that is used to map instances of
* the class between the relational database and their object representation.
*
* @param string $entityClassName The name of the entity class.
* @return Doctrine_Mapper The mapper object.
* @todo package:orm
*/
public function getMapper($className)
public function getMapper($entityClassName)
{
if (isset($this->_mappers[$className])) {
return $this->_mappers[$className];
if (isset($this->_mappers[$entityClassName])) {
return $this->_mappers[$entityClassName];
}
$customMapperClass = $className . 'Mapper';
$metadata = $this->getMetadata($className);
if (class_exists($customMapperClass, $this->getAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES)) &&
in_array('Doctrine_Mapper_Abstract', class_parents($customMapperClass))) {
$mapper = new $customMapperClass($className, $metadata);
$metadata = $this->getClassMetadata($entityClassName);
$customMapperClassName = $metadata->getCustomMapperClass();
if ($customMapperClassName !== null) {
$mapper = new $customMapperClassName($entityClassName, $metadata);
} else {
// instantiate correct mapper type
$inheritanceType = $metadata->getInheritanceType();
if ($inheritanceType == Doctrine::INHERITANCETYPE_JOINED) {
$mapper = new Doctrine_Mapper_Joined($className, $metadata);
$mapper = new Doctrine_Mapper_Joined($entityClassName, $metadata);
} else if ($inheritanceType == Doctrine::INHERITANCETYPE_SINGLE_TABLE) {
$mapper = new Doctrine_Mapper_SingleTable($className, $metadata);
$mapper = new Doctrine_Mapper_SingleTable($entityClassName, $metadata);
} else if ($inheritanceType == Doctrine::INHERITANCETYPE_TABLE_PER_CLASS) {
$mapper = new Doctrine_Mapper_TablePerClass($className, $metadata);
$mapper = new Doctrine_Mapper_TablePerClass($entityClassName, $metadata);
} else {
throw new Doctrine_Connection_Exception("Unknown inheritance type '$inheritanceType'. Can't create mapper.");
}
}
$this->_mappers[$className] = $mapper;
$this->_mappers[$entityClassName] = $mapper;
return $mapper;
}

View File

@ -29,6 +29,7 @@ Doctrine::autoload('Doctrine_Connection_Module');
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo package:orm. Figure out a useful implementation.
*/
class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
{
@ -39,7 +40,25 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
public function flush()
{
return $this->saveAll();
// get the flush tree
$tree = $this->buildFlushTree($this->conn->getMappers());
// save all records
foreach ($tree as $name) {
$mapper = $this->conn->getMapper($name);
foreach ($mapper->getRepository() as $record) {
//echo $record->getOid() . "<br />";
$mapper->saveSingleRecord($record);
}
}
// save all associations
foreach ($tree as $name) {
$mapper = $this->conn->getMapper($name);
foreach ($mapper->getRepository() as $record) {
$mapper->saveAssociations($record);
}
}
}
public function addInsert()
@ -69,14 +88,14 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
* @param array $tables an array of Doctrine_Table objects or component names
* @return array an array of component names in flushing order
*/
public function buildFlushTree(array $tables)
public function buildFlushTree(array $mappers)
{
$tree = array();
foreach ($tables as $k => $table) {
if ( ! ($table instanceof Doctrine_Mapper_Abstract)) {
$table = $this->conn->getMapper($table);
foreach ($mappers as $k => $mapper) {
if ( ! ($mapper instanceof Doctrine_Mapper_Abstract)) {
$mapper = $this->conn->getMapper($mapper);
}
$nm = $table->getComponentName();
$nm = $mapper->getComponentName();
$index = array_search($nm, $tree);
@ -85,7 +104,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
$index = max(array_keys($tree));
}
$rels = $table->getTable()->getRelations();
$rels = $mapper->getTable()->getRelations();
// group relations
@ -117,7 +136,6 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
} else {
$tree[] = $name;
}
} else if ($rel instanceof Doctrine_Relation_LocalKey) {
if ($index2 !== false) {
if ($index2 <= $index)
@ -156,393 +174,6 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
}
return array_values($tree);
}
/**
* saves the given record
*
* @param Doctrine_Record $record
* @return void
*/
/*public function saveGraph(Doctrine_Record $record)
{
$conn = $this->getConnection();
$state = $record->state();
if ($state === Doctrine_Record::STATE_LOCKED) {
return false;
}
$record->state(Doctrine_Record::STATE_LOCKED);
$conn->beginInternalTransaction();
$saveLater = $this->saveRelated($record);
$record->state($state);
if ($record->isValid()) {
$event = new Doctrine_Event($record, Doctrine_Event::RECORD_SAVE);
$record->preSave($event);
$record->getTable()->getRecordListener()->preSave($event);
$state = $record->state();
if ( ! $event->skipOperation) {
switch ($state) {
case Doctrine_Record::STATE_TDIRTY:
$this->insert($record);
break;
case Doctrine_Record::STATE_DIRTY:
case Doctrine_Record::STATE_PROXY:
$this->update($record);
break;
case Doctrine_Record::STATE_CLEAN:
case Doctrine_Record::STATE_TCLEAN:
break;
}
}
$record->getTable()->getRecordListener()->postSave($event);
$record->postSave($event);
} else {
$conn->transaction->addInvalid($record);
}
$state = $record->state();
$record->state(Doctrine_Record::STATE_LOCKED);
foreach ($saveLater as $fk) {
$alias = $fk->getAlias();
if ($record->hasReference($alias)) {
$obj = $record->$alias;
// check that the related object is not an instance of Doctrine_Null
if ( ! ($obj instanceof Doctrine_Null)) {
$obj->save($conn);
}
}
}
// save the MANY-TO-MANY associations
$this->saveAssociations($record);
$record->state($state);
$conn->commit();
return true;
}*/
/**
* saves the given record
*
* @param Doctrine_Record $record
* @return void
*/
/*public function save(Doctrine_Record $record)
{
$event = new Doctrine_Event($record, Doctrine_Event::RECORD_SAVE);
$record->preSave($event);
$record->getTable()->getRecordListener()->preSave($event);
if ( ! $event->skipOperation) {
switch ($record->state()) {
case Doctrine_Record::STATE_TDIRTY:
$this->insert($record);
break;
case Doctrine_Record::STATE_DIRTY:
case Doctrine_Record::STATE_PROXY:
$this->update($record);
break;
case Doctrine_Record::STATE_CLEAN:
case Doctrine_Record::STATE_TCLEAN:
// do nothing
break;
}
}
$record->getTable()->getRecordListener()->postSave($event);
$record->postSave($event);
}*/
/**
* deletes given record and all the related composites
* this operation is isolated by a transaction
*
* this event can be listened by the onPreDelete and onDelete listeners
*
* @return boolean true on success, false on failure
* @todo Move to Doctrine_Table (which will become Doctrine_Mapper).
*/
/*public function delete(Doctrine_Record $record)
{
if ( ! $this->_autoflush) {
return true;
}
if ( ! $record->exists()) {
return false;
}
$this->conn->beginInternalTransaction();
$event = new Doctrine_Event($record, Doctrine_Event::RECORD_DELETE);
$record->preDelete($event);
$table = $record->getTable();
$table->getRecordListener()->preDelete($event);
$state = $record->state();
$record->state(Doctrine_Record::STATE_LOCKED);
$this->deleteComposites($record);
if ( ! $event->skipOperation) {
$record->state(Doctrine_Record::STATE_TDIRTY);
if ($table->getInheritanceType() == Doctrine::INHERITANCETYPE_JOINED) {
foreach ($table->getOption('joinedParents') as $parent) {
$parentTable = $table->getConnection()->getTable($parent);
$this->conn->delete($parentTable, $record->identifier());
}
}
$this->conn->delete($table, $record->identifier());
$record->state(Doctrine_Record::STATE_TCLEAN);
} else {
// return to original state
$record->state($state);
}
$table->getRecordListener()->postDelete($event);
$record->postDelete($event);
$record->getMapper()->removeRecord($record);
$this->conn->commit();
return true;
}*/
/**
* @todo Description. See also the todo for deleteMultiple().
*/
/*public function deleteRecord(Doctrine_Record $record)
{
$ids = $record->identifier();
$tmp = array();
foreach (array_keys($ids) as $id) {
$tmp[] = $id . ' = ? ';
}
$params = array_values($ids);
$query = 'DELETE FROM '
. $this->conn->quoteIdentifier($record->getTable()->getTableName())
. ' WHERE ' . implode(' AND ', $tmp);
return $this->conn->exec($query, $params);
}*/
/**
* DOESNT SEEM TO BE USED ANYWHERE.
*
* deleteMultiple
* deletes all records from the pending delete list
*
* @return void
* @todo Refactor. Maybe move to the Connection class? Sometimes UnitOfWork constructs
* queries itself and sometimes it leaves the sql construction to Connection.
* This should be changed.
*/
/*public function deleteMultiple(array $records)
{
foreach ($this->delete as $name => $deletes) {
$record = false;
$ids = array();
// Note: Why is the last element's table identifier checked here and then
// the table object from $deletes[0] used???
if (is_array($deletes[count($deletes)-1]->getTable()->getIdentifier()) &&
count($deletes) > 0) {
$table = $deletes[0]->getTable();
$query = 'DELETE FROM '
. $this->conn->quoteIdentifier($table->getTableName())
. ' WHERE ';
$params = array();
$cond = array();
foreach ($deletes as $k => $record) {
$ids = $record->identifier();
$tmp = array();
foreach (array_keys($ids) as $id) {
$tmp[] = $table->getColumnName($id) . ' = ? ';
}
$params = array_merge($params, array_values($ids));
$cond[] = '(' . implode(' AND ', $tmp) . ')';
}
$query .= implode(' OR ', $cond);
$this->conn->execute($query, $params);
} else {
foreach ($deletes as $k => $record) {
$ids[] = $record->getIncremented();
}
// looks pretty messy. $record should be already out of scope. ugly php behaviour.
// even the php manual agrees on that and recommends to unset() the last element
// immediately after the loop ends.
$table = $record->getTable();
if ($record instanceof Doctrine_Record) {
$params = substr(str_repeat('?, ', count($ids)), 0, -2);
$query = 'DELETE FROM '
. $this->conn->quoteIdentifier($record->getTable()->getTableName())
. ' WHERE '
. $table->getColumnName($table->getIdentifier())
. ' IN(' . $params . ')';
$this->conn->execute($query, $ids);
}
}
}
}*/
/**
* saveRelated
* saves all related records to $record
*
* @throws PDOException if something went wrong at database level
* @param Doctrine_Record $record
*/
/*public function saveRelated(Doctrine_Record $record)
{
$saveLater = array();
foreach ($record->getReferences() as $k => $v) {
$rel = $record->getTable()->getRelation($k);
$local = $rel->getLocal();
$foreign = $rel->getForeign();
if ($rel instanceof Doctrine_Relation_ForeignKey) {
$saveLater[$k] = $rel;
} else if ($rel instanceof Doctrine_Relation_LocalKey) {
// ONE-TO-ONE relationship
$obj = $record->get($rel->getAlias());
// Protection against infinite function recursion before attempting to save
if ($obj instanceof Doctrine_Record && $obj->isModified()) {
$obj->save($this->conn);
}
}
}
return $saveLater;
}*/
/**
* saveAssociations
*
* this method takes a diff of one-to-many / many-to-many original and
* current collections and applies the changes
*
* for example if original many-to-many related collection has records with
* primary keys 1,2 and 3 and the new collection has records with primary keys
* 3, 4 and 5, this method would first destroy the associations to 1 and 2 and then
* save new associations to 4 and 5
*
* @throws Doctrine_Connection_Exception if something went wrong at database level
* @param Doctrine_Record $record
* @return void
*/
/*public function saveAssociations(Doctrine_Record $record)
{
foreach ($record->getReferences() as $k => $v) {
$rel = $record->getTable()->getRelation($k);
if ($rel instanceof Doctrine_Relation_Association) {
$v->save($this->conn);
$assocTable = $rel->getAssociationTable();
foreach ($v->getDeleteDiff() as $r) {
$query = 'DELETE FROM ' . $assocTable->getTableName()
. ' WHERE ' . $rel->getForeign() . ' = ?'
. ' AND ' . $rel->getLocal() . ' = ?';
$this->conn->execute($query, array($r->getIncremented(), $record->getIncremented()));
}
foreach ($v->getInsertDiff() as $r) {
$assocRecord = $assocTable->create();
$assocRecord->set($assocTable->getFieldName($rel->getForeign()), $r);
$assocRecord->set($assocTable->getFieldName($rel->getLocal()), $record);
$this->saveGraph($assocRecord);
}
}
}
}*/
/**
* deletes all related composites
* this method is always called internally when a record is deleted
*
* @throws PDOException if something went wrong at database level
* @return void
*/
/*public function deleteComposites(Doctrine_Record $record)
{
foreach ($record->getTable()->getRelations() as $fk) {
if ($fk->isComposite()) {
$obj = $record->get($fk->getAlias());
if ($obj instanceof Doctrine_Record &&
$obj->state() != Doctrine_Record::STATE_LOCKED) {
$obj->delete($this->conn);
}
}
}
}*/
/**
* saveAll
* persists all the pending records from all tables
*
* @throws PDOException if something went wrong at database level
* @return void
*/
/*public function saveAll()
{
// get the flush tree
$tree = $this->buildFlushTree($this->conn->getTables());
// save all records
foreach ($tree as $name) {
$table = $this->conn->getTable($name);
foreach ($table->getRepository() as $record) {
$table->save($record);
}
}
// save all associations
foreach ($tree as $name) {
$table = $this->conn->getTable($name);
foreach ($table->getRepository() as $record) {
$table->saveAssociations($record);
}
}
}*/
/**
* saveAll
@ -550,182 +181,11 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
*
* @throws PDOException if something went wrong at database level
* @return void
* @deprecated
*/
public function saveAll()
{
//echo "<br /><br />flushin all.<br /><br />";
// get the flush tree
$tree = $this->buildFlushTree($this->conn->getMappers());
// save all records
foreach ($tree as $name) {
$mapper = $this->conn->getMapper($name);
foreach ($mapper->getRepository() as $record) {
//echo $record->getOid() . "<br />";
$mapper->saveSingleRecord($record);
}
}
// save all associations
foreach ($tree as $name) {
$mapper = $this->conn->getMapper($name);
foreach ($mapper->getRepository() as $record) {
$mapper->saveAssociations($record);
}
}
return $this->flush();
}
/**
* updates given record
*
* @param Doctrine_Record $record record to be updated
* @return boolean whether or not the update was successful
* @todo Move to Doctrine_Table (which will become Doctrine_Mapper).
*/
/*public function update(Doctrine_Record $record)
{
if ( ! $this->_autoflush) {
return true;
}
$event = new Doctrine_Event($record, Doctrine_Event::RECORD_UPDATE);
$record->preUpdate($event);
$table = $record->getTable();
$table->getRecordListener()->preUpdate($event);
if ( ! $event->skipOperation) {
$identifier = $record->identifier();
if ($table->getInheritanceType() == Doctrine::INHERITANCETYPE_JOINED
&& count($table->getOption('joinedParents')) > 0) {
$dataSet = $this->formatDataSet($record);
$component = $table->getComponentName();
$classes = $table->getOption('joinedParents');
$classes[] = $component;
foreach ($record as $field => $value) {
if ($value instanceof Doctrine_Record) {
if ( ! $value->exists()) {
$value->save();
}
$record->set($field, $value->getIncremented());
}
}
foreach ($classes as $class) {
$parentTable = $this->conn->getTable($class);
$this->conn->update($parentTable, $dataSet[$class], $identifier);
}
} else {
$array = $record->getPrepared();
$this->conn->update($table, $array, $identifier);
}
$record->assignIdentifier(true);
}
$table->getRecordListener()->postUpdate($event);
$record->postUpdate($event);
return true;
}*/
/**
* inserts a record into database
*
* @param Doctrine_Record $record record to be inserted
* @return boolean
* @todo Move to Doctrine_Table (which will become Doctrine_Mapper).
*/
/*public function insert(Doctrine_Record $record)
{
if ( ! $this->_autoflush) {
return true;
}
// listen the onPreInsert event
$event = new Doctrine_Event($record, Doctrine_Event::RECORD_INSERT);
$record->preInsert($event);
$table = $record->getTable();
$table->getRecordListener()->preInsert($event);
if ( ! $event->skipOperation) {
if ($table->getInheritanceType() == Doctrine::INHERITANCETYPE_JOINED &&
count($table->getOption('joinedParents')) > 0) {
$dataSet = $this->formatDataSet($record);
$component = $table->getComponentName();
$classes = $table->getOption('joinedParents');
$classes[] = $component;
foreach ($classes as $k => $parent) {
if ($k === 0) {
$rootRecord = new $parent();
$rootRecord->merge($dataSet[$parent]);
$this->processSingleInsert($rootRecord);
$record->assignIdentifier($rootRecord->identifier());
} else {
foreach ((array) $rootRecord->identifier() as $id => $value) {
$dataSet[$parent][$id] = $value;
}
$this->conn->insert($this->conn->getTable($parent), $dataSet[$parent]);
}
}
} else {
$this->processSingleInsert($record);
}
}
$table->addRecord($record);
$table->getRecordListener()->postInsert($event);
$record->postInsert($event);
return true;
}*/
/**
* @todo DESCRIBE WHAT THIS METHOD DOES, PLEASE!
*/
/*public function formatDataSet(Doctrine_Record $record)
{
$table = $record->getTable();
$dataSet = array();
$component = $table->getComponentName();
$array = $record->getPrepared();
foreach ($table->getColumns() as $columnName => $definition) {
$fieldName = $table->getFieldName($columnName);
if (isset($definition['primary']) && $definition['primary']) {
continue;
}
if (isset($definition['owner'])) {
$dataSet[$definition['owner']][$fieldName] = $array[$fieldName];
} else {
$dataSet[$component][$fieldName] = $array[$fieldName];
}
}
return $dataSet;
}*/
}

View File

@ -330,6 +330,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*
* @param array $dsn An array of dsn information
* @return array The array parsed
* @todo package:dbal
*/
public function parsePdoDsn($dsn)
{
@ -367,6 +368,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*
* @param string $dsn
* @return array Parsed contents of DSN
* @todo package:dbal
*/
public function parseDsn($dsn)
{
@ -599,6 +601,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
* @see Doctrine_Connection::getTable()
* @param string $componentName
* @return Doctrine_Table
* @deprecated
*/
public function getTable($componentName)
{
@ -698,6 +701,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
* returns the number of opened connections
*
* @return integer
* @todo This is unintuitive.
*/
public function count()
{
@ -738,6 +742,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*
* @param string $specifiedConnections Array of connections you wish to create the database for
* @return void
* @todo package:dbal
*/
public function createDatabases($specifiedConnections = array())
{
@ -765,6 +770,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*
* @param string $specifiedConnections Array of connections you wish to drop the database for
* @return void
* @todo package:dbal
*/
public function dropDatabases($specifiedConnections = array())
{

View File

@ -33,13 +33,15 @@ Doctrine::autoload('Doctrine_Access');
abstract class Doctrine_Record_Abstract extends Doctrine_Access
{
/**
* @param Doctrine_Table $_table reference to associated Doctrine_Table instance
* The metadata container that describes the entity class.
*
* @param Doctrine_ClassMetadata
*/
protected $_table;
/**
*
* @var Doctrine_Mapper_Abstract
* @var Doctrine_Mapper
*/
protected $_mapper;
@ -77,6 +79,8 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access
/**
* Returns the mapper of the entity.
*
* @return Doctrine_Mapper
*/
public function getMapper()
{

View File

@ -6,6 +6,7 @@
*
* @package Doctrine
* @author Roman Borschel <roman@code-factory.org>
* @todo Remove or is there use for such a class in the DBAL?
*/
class Doctrine_Table extends Doctrine_Configurable implements Serializable
{

14
tests/fixtures/forum/common/admins.php vendored Normal file
View File

@ -0,0 +1,14 @@
<?php
$fixture = array(
'model' => 'ForumAdministrator',
'rows' => array(
array(
'id' => 1,
'foo' => 'bar'
),
array(
'id' => 2,
'foo' => 'bar2'
)
)
);