diff --git a/UPGRADE_TO_2_0 b/UPGRADE_TO_2_0 index 9181fc3df..134c9dade 100644 --- a/UPGRADE_TO_2_0 +++ b/UPGRADE_TO_2_0 @@ -1,4 +1,90 @@ -Upgrade to Doctrine 2.0 -####################### +## Installing -More information coming soon... +Currently the only way to install is via svn. So just checkout the trunk. + + $ svn co http://svn.doctrine-project.org/trunk/lib doctrine + $ cd doctrine + +## Loading Doctrine + +First we need to require one class, the `ClassLoader`. + +>**NOTE** +> This assumes you've created some kind of script to test the following code in. Something like a `test.php` file. + + [php] + // test.php + + require_once 'lib/Doctrine/Common/ClassLoader.php'; + +Now we need to instantiate the `ClassLoader` and register it: + + [php] + $classLoader = new \Doctrine\Common\ClassLoader(); + $classLoader->register(); + +The Doctrine `ClassLoader` supports the ability to use it for loading other classes with a prefix. + +Here are the recommend usages for the Doctrine `ClassLoader`: + +* Use only 1 class loader instance. +* Set the base paths to your class libraries (including Doctrine's) through + +- + + [php] + $classLoader->setBasePath($prefix, $basePath); + +For example you can set the path for Doctrine with the following: + + [php] + $classLoader->setBasePath('Doctrine', '/usr/local/phplibs/doctrine/lib'); + +Then, when trying to load the class Doctrine\ORM\EntityManager, for example the class loader will look for /usr/local/phplibs/doctrine/lib/Doctrine/ORM/EntityManager.php + +* DO NOT setCheckFileExists(true). Doing so is expensive in terms of performance. +* Use an opcode-cache (i.e. APC) (STRONGLY RECOMMENDED). + +## Initialize Doctrine + + [php] + $config = new \Doctrine\ORM\Configuration(); + $config->setMetadataCacheImpl(new \Doctrine\ORM\Cache\ArrayCache); + $eventManager = new \Doctrine\Common\EventManager(); + $connectionOptions = array( + 'user' => 'john', + 'password' => 'wayne' + ); + $em = \Doctrine\ORM\EntityManager::create($connectionOptions, 'doctrine', $config, $eventManager); + +## Getting the Connection + + [php] + $conn = $em->getConnection(); + $conn->delete('table_name', array(1, 3, 10)); + +The DBAL Connection class has lots of useful functions. You can browse the code and check the API to get familiar. + +## The Schema Manager + +The schema manager is a nice API for issuing database DDL statements like creating a table, or dropping a table. + + [php] + $sm = $connection->getSchemaManager(); + +The schema manager allows you to do all the familiar options on your schema. Like `createTable()`. Below you will find an example: + + [php] + $sm->createTable($tableName, $columns, $options); + +## The Platform Object + +The platform object is the object that provides the appropriate SQL to the schema manager for the DDL statements. + + [php] + $platform = $connection->getDatabasePlatform(); + +Now we can get the generated SQL instead of executing it directly: + + [php] + $sql = $platform->getCreateTableSql($tableName, $columns, $options); \ No newline at end of file diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 101b97d5d..b370307e0 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -59,14 +59,6 @@ class EntityManager */ const FLUSHMODE_MANUAL = 'manual'; - /** - * The currently active EntityManager. Only one EntityManager can be active - * at any time. - * - * @var Doctrine\ORM\EntityManager - */ - private static $_activeEm; - /** * The unique name of the EntityManager. * @@ -536,18 +528,6 @@ class EntityManager return $this->_unitOfWork; } - /** - * Checks whether this EntityManager is the currently active one. - * - * Note:This is only useful in scenarios where {@link ActiveEntity}s are used. - * - * @return boolean - */ - public function isActive() - { - return self::$_activeEm === $this; - } - /** * Gets a hydrator for the given hydration mode. * @@ -593,16 +573,6 @@ class EntityManager $this->_hydrators[$hydrationMode] = $hydrator; } - /** - * Makes this EntityManager the currently active one. - * - * Note: This is only useful in scenarios where {@link ActiveEntity}s are used. - */ - public function activate() - { - self::$_activeEm = $this; - } - /** * Factory method to create EntityManager instances. * @@ -636,17 +606,4 @@ class EntityManager return $em; } - - /** - * Static lookup to get the currently active EntityManager. - * - * Note: Used by {@link ActiveEntity}s to actively lookup an EntityManager. - * - * @return Doctrine\ORM\EntityManager - */ - public static function getActiveEntityManager() - { - return self::$_activeEm; - } -} - +} \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/EntityPersisterTest.php b/tests/Doctrine/Tests/ORM/EntityPersisterTest.php index ec2caa5e4..95384a398 100644 --- a/tests/Doctrine/Tests/ORM/EntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/EntityPersisterTest.php @@ -35,8 +35,6 @@ class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase $this->_emMock->setUnitOfWork($this->_uowMock); $this->_idGenMock = new SequenceMock($this->_emMock); $this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumUser', $this->_idGenMock); - - $this->_emMock->activate(); } public function testSimpleInsert() { diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index d78f29050..8a9e896e2 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -15,7 +15,8 @@ class OrmTestCase extends DoctrineTestCase * * @return Doctrine\ORM\EntityManager */ - protected function _getTestEntityManager($conf = null, $eventManager = null) { + protected function _getTestEntityManager($conf = null, $eventManager = null) + { $config = new \Doctrine\ORM\Configuration(); $config->setMetadataCacheImpl(self::getSharedMetadataCacheImpl()); $eventManager = new \Doctrine\Common\EventManager();