Commit df6ca602 authored by romanb's avatar romanb

[2.0][DDC-92] Fixed. Patch provided by Christian Heinrich. [DDC-274] Started...

[2.0][DDC-92] Fixed. Patch provided by Christian Heinrich. [DDC-274] Started some method renaming. [DDC-142] Fixed (join column names and discriminator column names dont support quoting) [DDC-258] Fixed.
parent 715da59d
...@@ -32,14 +32,14 @@ namespace Doctrine\Common\Annotations; ...@@ -32,14 +32,14 @@ namespace Doctrine\Common\Annotations;
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class AnnotationException extends \Doctrine\Common\DoctrineException class AnnotationException extends \Doctrine\Common\CommonException
{ {
public static function syntaxError($message) public static function syntaxError($message)
{ {
return new self('[Syntax Error] ' . $message); return new self('[Syntax Error] ' . $message);
} }
public static function semanticalError($message) public static function semanticalError($message)
{ {
return new self('[Semantical Error] ' . $message); return new self('[Semantical Error] ' . $message);
......
...@@ -105,7 +105,9 @@ class AnnotationReader ...@@ -105,7 +105,9 @@ class AnnotationReader
public function getClassAnnotations(ReflectionClass $class) public function getClassAnnotations(ReflectionClass $class)
{ {
$cacheKey = $class->getName() . self::$CACHE_SALT; $cacheKey = $class->getName() . self::$CACHE_SALT;
//FIXME: Just use ->fetch(), otherwise some drivers, i.e. APC will fetch twice because they
// implement contains() in terms of fetch(), *sigh*.
if ($this->_cache->contains($cacheKey)) { if ($this->_cache->contains($cacheKey)) {
return $this->_cache->fetch($cacheKey); return $this->_cache->fetch($cacheKey);
} }
...@@ -140,7 +142,9 @@ class AnnotationReader ...@@ -140,7 +142,9 @@ class AnnotationReader
public function getPropertyAnnotations(ReflectionProperty $property) public function getPropertyAnnotations(ReflectionProperty $property)
{ {
$cacheKey = $property->getDeclaringClass()->getName() . '$' . $property->getName() . self::$CACHE_SALT; $cacheKey = $property->getDeclaringClass()->getName() . '$' . $property->getName() . self::$CACHE_SALT;
//FIXME: Just use ->fetch(), otherwise some drivers, i.e. APC will fetch twice because they
// implement contains() in terms of fetch(), *sigh*.
if ($this->_cache->contains($cacheKey)) { if ($this->_cache->contains($cacheKey)) {
return $this->_cache->fetch($cacheKey); return $this->_cache->fetch($cacheKey);
} }
...@@ -176,7 +180,9 @@ class AnnotationReader ...@@ -176,7 +180,9 @@ class AnnotationReader
public function getMethodAnnotations(ReflectionMethod $method) public function getMethodAnnotations(ReflectionMethod $method)
{ {
$cacheKey = $method->getDeclaringClass()->getName() . '#' . $method->getName() . self::$CACHE_SALT; $cacheKey = $method->getDeclaringClass()->getName() . '#' . $method->getName() . self::$CACHE_SALT;
//FIXME: Just use ->fetch(), otherwise some drivers, i.e. APC will fetch twice because they
// implement contains() in terms of fetch(), *sigh*.
if ($this->_cache->contains($cacheKey)) { if ($this->_cache->contains($cacheKey)) {
return $this->_cache->fetch($cacheKey); return $this->_cache->fetch($cacheKey);
} }
......
This diff is collapsed.
...@@ -18,11 +18,10 @@ ...@@ -18,11 +18,10 @@
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli; namespace Doctrine\Common\Cli;
use Doctrine\Common\Util\Inflector, use Doctrine\Common\Util\Inflector;
Doctrine\Common\DoctrineException;
/** /**
* Abstract CLI Namespace class * Abstract CLI Namespace class
...@@ -42,22 +41,22 @@ abstract class AbstractNamespace ...@@ -42,22 +41,22 @@ abstract class AbstractNamespace
* @var Configuration CLI Configuration instance * @var Configuration CLI Configuration instance
*/ */
private $_configuration = null; private $_configuration = null;
/** /**
* @var AbstractPrinter CLI Printer instance * @var AbstractPrinter CLI Printer instance
*/ */
private $_printer = null; private $_printer = null;
/** /**
* @var AbstractNamespace CLI Namespace instance * @var AbstractNamespace CLI Namespace instance
*/ */
private $_parentNamespace = null; private $_parentNamespace = null;
/** /**
* @var array Available namespaces * @var array Available namespaces
*/ */
private $_namespaces = array(); private $_namespaces = array();
/** /**
* Add a single namespace to CLI. * Add a single namespace to CLI.
* Example of inclusion support to a single namespace: * Example of inclusion support to a single namespace:
...@@ -72,14 +71,14 @@ abstract class AbstractNamespace ...@@ -72,14 +71,14 @@ abstract class AbstractNamespace
public function addNamespace($name) public function addNamespace($name)
{ {
$name = self::formatName($name); $name = self::formatName($name);
if ($this->hasNamespace($name)) { if ($this->hasNamespace($name)) {
throw DoctrineException::cannotOverrideNamespace($name); throw CliException::cannotOverrideNamespace($name);
} }
return $this->overrideNamespace($name); return $this->overrideNamespace($name);
} }
/** /**
* Overrides a namespace to CLI. * Overrides a namespace to CLI.
* Example of inclusion support to a single namespace: * Example of inclusion support to a single namespace:
...@@ -92,18 +91,18 @@ abstract class AbstractNamespace ...@@ -92,18 +91,18 @@ abstract class AbstractNamespace
* @return AbstractNamespace Newly created CLI Namespace * @return AbstractNamespace Newly created CLI Namespace
*/ */
public function overrideNamespace($name) public function overrideNamespace($name)
{ {
$taskNamespace = new TaskNamespace($name); $taskNamespace = new TaskNamespace($name);
$taskNamespace->setParentNamespace($this); $taskNamespace->setParentNamespace($this);
$taskNamespace->setPrinter($this->_printer); $taskNamespace->setPrinter($this->_printer);
$taskNamespace->setConfiguration($this->_configuration); $taskNamespace->setConfiguration($this->_configuration);
$this->_namespaces[$taskNamespace->getName()] = $taskNamespace; $this->_namespaces[$taskNamespace->getName()] = $taskNamespace;
return $taskNamespace; return $taskNamespace;
} }
/** /**
* Retrieve CLI Namespace. * Retrieve CLI Namespace.
* Example of usage: * Example of usage:
...@@ -118,11 +117,11 @@ abstract class AbstractNamespace ...@@ -118,11 +117,11 @@ abstract class AbstractNamespace
public function getNamespace($name) public function getNamespace($name)
{ {
$name = self::formatName($name); $name = self::formatName($name);
return isset($this->_namespaces[$name]) return isset($this->_namespaces[$name])
? $this->_namespaces[$name] : null; ? $this->_namespaces[$name] : null;
} }
/** /**
* Check existance of a CLI Namespace * Check existance of a CLI Namespace
* *
...@@ -134,7 +133,7 @@ abstract class AbstractNamespace ...@@ -134,7 +133,7 @@ abstract class AbstractNamespace
{ {
return ($this->getNamespace($name) !== null); return ($this->getNamespace($name) !== null);
} }
/** /**
* Defines the parent CLI Namespace * Defines the parent CLI Namespace
* *
...@@ -143,10 +142,10 @@ abstract class AbstractNamespace ...@@ -143,10 +142,10 @@ abstract class AbstractNamespace
public function setParentNamespace(AbstractNamespace $namespace) public function setParentNamespace(AbstractNamespace $namespace)
{ {
$this->_parentNamespace = $namespace; $this->_parentNamespace = $namespace;
return $this; return $this;
} }
/** /**
* Retrieves currently parent CLI Namespace * Retrieves currently parent CLI Namespace
* *
...@@ -156,7 +155,7 @@ abstract class AbstractNamespace ...@@ -156,7 +155,7 @@ abstract class AbstractNamespace
{ {
return $this->_parentNamespace; return $this->_parentNamespace;
} }
/** /**
* Retrieve all defined CLI Tasks * Retrieve all defined CLI Tasks
* *
...@@ -165,14 +164,14 @@ abstract class AbstractNamespace ...@@ -165,14 +164,14 @@ abstract class AbstractNamespace
public function getAvailableTasks() public function getAvailableTasks()
{ {
$tasks = array(); $tasks = array();
foreach ($this->_namespaces as $namespace) { foreach ($this->_namespaces as $namespace) {
$tasks = array_merge($tasks, $namespace->getAvailableTasks()); $tasks = array_merge($tasks, $namespace->getAvailableTasks());
} }
return $tasks; return $tasks;
} }
/** /**
* Defines the CLI Output Printer * Defines the CLI Output Printer
* *
...@@ -183,10 +182,10 @@ abstract class AbstractNamespace ...@@ -183,10 +182,10 @@ abstract class AbstractNamespace
public function setPrinter(Printers\AbstractPrinter $printer = null) public function setPrinter(Printers\AbstractPrinter $printer = null)
{ {
$this->_printer = $printer ?: new Printers\AnsiColorPrinter; $this->_printer = $printer ?: new Printers\AnsiColorPrinter;
return $this; return $this;
} }
/** /**
* Retrieves currently used CLI Output Printer * Retrieves currently used CLI Output Printer
* *
...@@ -196,7 +195,7 @@ abstract class AbstractNamespace ...@@ -196,7 +195,7 @@ abstract class AbstractNamespace
{ {
return $this->_printer; return $this->_printer;
} }
/** /**
* Defines the CLI Configuration * Defines the CLI Configuration
* *
...@@ -207,10 +206,10 @@ abstract class AbstractNamespace ...@@ -207,10 +206,10 @@ abstract class AbstractNamespace
public function setConfiguration(Configuration $config) public function setConfiguration(Configuration $config)
{ {
$this->_configuration = $config; $this->_configuration = $config;
return $this; return $this;
} }
/** /**
* Retrieves currently used CLI Configuration * Retrieves currently used CLI Configuration
* *
...@@ -220,7 +219,7 @@ abstract class AbstractNamespace ...@@ -220,7 +219,7 @@ abstract class AbstractNamespace
{ {
return $this->_configuration; return $this->_configuration;
} }
/** /**
* Formats the CLI Namespace name into a camel-cased name * Formats the CLI Namespace name into a camel-cased name
* *
......
...@@ -18,10 +18,8 @@ ...@@ -18,10 +18,8 @@
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli;
use Doctrine\Common\DoctrineException; namespace Doctrine\Common\Cli;
/** /**
* CLI Exception class * CLI Exception class
...@@ -35,12 +33,12 @@ use Doctrine\Common\DoctrineException; ...@@ -35,12 +33,12 @@ use Doctrine\Common\DoctrineException;
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class CliException extends DoctrineException class CliException extends \Doctrine\Common\CommonException
{ {
public static function namespaceDoesNotExist($namespaceName, $namespacePath = '') public static function namespaceDoesNotExist($namespaceName, $namespacePath = '')
{ {
return new self( return new self(
"Namespace '{$namespaceName}' does not exist" . "Namespace '{$namespaceName}' does not exist" .
(( ! empty($namespacePath)) ? " in '{$namespacePath}'." : '.') (( ! empty($namespacePath)) ? " in '{$namespacePath}'." : '.')
); );
} }
...@@ -49,9 +47,13 @@ class CliException extends DoctrineException ...@@ -49,9 +47,13 @@ class CliException extends DoctrineException
{ {
return new self("Task '{$taskName}' does not exist in '{$namespacePath}'."); return new self("Task '{$taskName}' does not exist in '{$namespacePath}'.");
} }
public static function cannotOverrideTask($taskName) public static function cannotOverrideTask($taskName)
{ {
return new self("Task '{$taskName}' cannot be overriden."); return new self("Task '{$taskName}' cannot be overriden.");
} }
public static function cannotOverrideNamespace($namespace) {
return new self("Namespace '$namespace' cannot be overriden. Call overrideNamespace() directly.");
}
} }
\ No newline at end of file
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common\Cli; namespace Doctrine\Common\Cli;
/** /**
...@@ -39,7 +39,7 @@ class TaskNamespace extends AbstractNamespace ...@@ -39,7 +39,7 @@ class TaskNamespace extends AbstractNamespace
* @var boolean CLI Tasks flag to check if they are already initialized * @var boolean CLI Tasks flag to check if they are already initialized
*/ */
private $_initialized = false; private $_initialized = false;
/** /**
* @var string CLI Namespace full name * @var string CLI Namespace full name
*/ */
...@@ -49,12 +49,12 @@ class TaskNamespace extends AbstractNamespace ...@@ -49,12 +49,12 @@ class TaskNamespace extends AbstractNamespace
* @var string CLI Namespace name * @var string CLI Namespace name
*/ */
private $_name = null; private $_name = null;
/** /**
* @var array Available tasks * @var array Available tasks
*/ */
private $_tasks = array(); private $_tasks = array();
/** /**
* The CLI namespace * The CLI namespace
* *
...@@ -63,8 +63,8 @@ class TaskNamespace extends AbstractNamespace ...@@ -63,8 +63,8 @@ class TaskNamespace extends AbstractNamespace
public function __construct($name) public function __construct($name)
{ {
$this->_name = self::formatName($name); $this->_name = self::formatName($name);
} }
/** /**
* Retrieve an instantiated CLI Task by given its name. * Retrieve an instantiated CLI Task by given its name.
* *
...@@ -74,16 +74,16 @@ class TaskNamespace extends AbstractNamespace ...@@ -74,16 +74,16 @@ class TaskNamespace extends AbstractNamespace
*/ */
public function getTask($name) public function getTask($name)
{ {
// Check if task exists in namespace // Check if task exists in namespace
if ($this->hasTask($name)) { if ($this->hasTask($name)) {
$taskClass = $this->_tasks[self::formatName($name)]; $taskClass = $this->_tasks[self::formatName($name)];
return new $taskClass($this); return new $taskClass($this);
} }
throw CliException::taskDoesNotExist($name, $this->getFullName()); throw CliException::taskDoesNotExist($name, $this->getFullName());
} }
/** /**
* Retrieve all CLI Task in this Namespace. * Retrieve all CLI Task in this Namespace.
* *
...@@ -93,7 +93,7 @@ class TaskNamespace extends AbstractNamespace ...@@ -93,7 +93,7 @@ class TaskNamespace extends AbstractNamespace
{ {
return $this->_tasks; return $this->_tasks;
} }
/** /**
* Retrieve all defined CLI Tasks * Retrieve all defined CLI Tasks
* *
...@@ -102,16 +102,16 @@ class TaskNamespace extends AbstractNamespace ...@@ -102,16 +102,16 @@ class TaskNamespace extends AbstractNamespace
public function getAvailableTasks() public function getAvailableTasks()
{ {
$tasks = parent::getAvailableTasks(); $tasks = parent::getAvailableTasks();
foreach ($this->_tasks as $taskName => $taskClass) { foreach ($this->_tasks as $taskName => $taskClass) {
$fullName = $this->getFullName() . ':' . $taskName; $fullName = $this->getFullName() . ':' . $taskName;
$tasks[$fullName] = $taskClass; $tasks[$fullName] = $taskClass;
} }
return $tasks; return $tasks;
} }
/** /**
* Add a single task to CLI Namespace. * Add a single task to CLI Namespace.
* Example of inclusion support to a single task: * Example of inclusion support to a single task:
...@@ -127,14 +127,14 @@ class TaskNamespace extends AbstractNamespace ...@@ -127,14 +127,14 @@ class TaskNamespace extends AbstractNamespace
public function addTask($name, $class) public function addTask($name, $class)
{ {
$name = self::formatName($name); $name = self::formatName($name);
if ($this->hasTask($name)) { if ($this->hasTask($name)) {
throw DoctrineException::cannotOverrideTask($name); throw CliException::cannotOverrideTask($name);
} }
return $this->overrideTask($name, $class); return $this->overrideTask($name, $class);
} }
/** /**
* Overrides task on CLI Namespace. * Overrides task on CLI Namespace.
* Example of inclusion support to a single task: * Example of inclusion support to a single task:
...@@ -148,14 +148,14 @@ class TaskNamespace extends AbstractNamespace ...@@ -148,14 +148,14 @@ class TaskNamespace extends AbstractNamespace
* @return TaskNamespace This object instance * @return TaskNamespace This object instance
*/ */
public function overrideTask($name, $class) public function overrideTask($name, $class)
{ {
$name = self::formatName($name); $name = self::formatName($name);
$this->_tasks[$name] = $class; $this->_tasks[$name] = $class;
return $this; return $this;
} }
/** /**
* Check existance of a CLI Task * Check existance of a CLI Task
* *
...@@ -166,10 +166,10 @@ class TaskNamespace extends AbstractNamespace ...@@ -166,10 +166,10 @@ class TaskNamespace extends AbstractNamespace
public function hasTask($name) public function hasTask($name)
{ {
$name = self::formatName($name); $name = self::formatName($name);
return isset($this->_tasks[$name]); return isset($this->_tasks[$name]);
} }
/** /**
* Retrieves the CLI Namespace name * Retrieves the CLI Namespace name
* *
...@@ -179,7 +179,7 @@ class TaskNamespace extends AbstractNamespace ...@@ -179,7 +179,7 @@ class TaskNamespace extends AbstractNamespace
{ {
return $this->_name; return $this->_name;
} }
/** /**
* Retrieves the full CLI Namespace name * Retrieves the full CLI Namespace name
* *
...@@ -189,20 +189,20 @@ class TaskNamespace extends AbstractNamespace ...@@ -189,20 +189,20 @@ class TaskNamespace extends AbstractNamespace
{ {
if ($this->_fullName === null) { if ($this->_fullName === null) {
$str = $this->_name; $str = $this->_name;
while ( while (
($parentNamespace = $this->getParentNamespace()) !== null && ($parentNamespace = $this->getParentNamespace()) !== null &&
! ($parentNamespace instanceof CliController) ! ($parentNamespace instanceof CliController)
) { ) {
$str = $parentNamespace->getFullName() . ':' . $str; $str = $parentNamespace->getFullName() . ':' . $str;
} }
$this->_fullName = $str; $this->_fullName = $str;
} }
return $this->_fullName; return $this->_fullName;
} }
/** /**
* Effectively instantiate and execute a given CLI Task * Effectively instantiate and execute a given CLI Task
* *
...@@ -213,14 +213,14 @@ class TaskNamespace extends AbstractNamespace ...@@ -213,14 +213,14 @@ class TaskNamespace extends AbstractNamespace
{ {
try { try {
$task = $this->getTask($name); $task = $this->getTask($name);
// Merge global configuration if it exists // Merge global configuration if it exists
if (($globalArgs = $this->getConfiguration()->getAttribute('globalArguments')) !== null) { if (($globalArgs = $this->getConfiguration()->getAttribute('globalArguments')) !== null) {
$arguments = array_merge($globalArgs, $arguments); $arguments = array_merge($globalArgs, $arguments);
} }
$task->setArguments($arguments); $task->setArguments($arguments);
if ((isset($arguments['help']) && $arguments['help']) || (isset($arguments['h']) && $arguments['h'])) { if ((isset($arguments['help']) && $arguments['help']) || (isset($arguments['h']) && $arguments['h'])) {
$task->extendedHelp(); // User explicitly asked for help option $task->extendedHelp(); // User explicitly asked for help option
} else if (isset($arguments['basic-help']) && $arguments['basic-help']) { } else if (isset($arguments['basic-help']) && $arguments['basic-help']) {
...@@ -228,23 +228,23 @@ class TaskNamespace extends AbstractNamespace ...@@ -228,23 +228,23 @@ class TaskNamespace extends AbstractNamespace
} else if ($task->validate()) { } else if ($task->validate()) {
$task->run(); $task->run();
} }
} catch (DoctrineException $e) { } catch (CliException $e) {
$message = $this->getFullName() . ':' . $name . ' => ' . $e->getMessage(); $message = $this->getFullName() . ':' . $name . ' => ' . $e->getMessage();
$printer = $this->getPrinter(); $printer = $this->getPrinter();
// If we want the trace of calls, append to error message // If we want the trace of calls, append to error message
if (isset($arguments['trace']) && $arguments['trace']) { if (isset($arguments['trace']) && $arguments['trace']) {
$message .= PHP_EOL . PHP_EOL . $e->getTraceAsString(); $message .= PHP_EOL . PHP_EOL . $e->getTraceAsString();
} }
$printer->writeln($messageMessage, 'ERROR'); $printer->writeln($messageMessage, 'ERROR');
// Unable instantiate task or task is not valid // Unable instantiate task or task is not valid
if ($task !== null) { if ($task !== null) {
$printer->write(PHP_EOL); $printer->write(PHP_EOL);
$task->basicHelp(); // Fallback of not-valid task arguments $task->basicHelp(); // Fallback of not-valid task arguments
} }
$printer->write(PHP_EOL); $printer->write(PHP_EOL);
} }
} }
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Common;
/**
* Base Exception class of Doctrine
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @todo Remove
*/
class DoctrineException extends \Exception
{
/**
* @var array Lazy initialized array of error messages
* @static
*/
private static $_messages = array();
/**
* Initializes a new DoctrineException.
*
* @param string $message
* @param Exception $cause Optional Exception
*/
public function __construct($message = "", \Exception $cause = null)
{
$code = ($cause instanceof Exception) ? $cause->getCode() : 0;
parent::__construct($message, $code, $cause);
}
/**
* Throws a DoctrineException reporting not implemented method in a given class
*
* @static
* @param string $method Method name
* @param string $class Class name
* @throws DoctrineException
*/
public static function notImplemented($method = null, $class = null)
{
if ($method && $class) {
return new self("The method '$method' is not implemented in class '$class'.");
} else if ($method && ! $class) {
return new self($method);
} else {
return new self('Functionality is not implemented.');
}
}
/**
* Implementation of __callStatic magic method.
*
* Received a method name and arguments. It lookups a $_messages HashMap
* for matching Class#Method key and executes the returned string value
* translating the placeholders with arguments passed.
*
* @static
* @param string $method Method name
* @param array $arguments Optional arguments to be translated in placeholders
* @throws DoctrineException
*/
public static function __callStatic($method, $arguments = array())
{
$class = get_called_class();
$messageKey = substr($class, strrpos($class, '\\') + 1) . "#$method";
$end = end($arguments);
$innerException = null;
if ($end instanceof \Exception) {
$innerException = $end;
unset($arguments[count($arguments) - 1]);
}
if (($message = self::getExceptionMessage($messageKey)) !== false) {
$message = sprintf($message, $arguments);
} else {
//$dumper = function ($value) { return var_export($value, true); };
$message = strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $method));
$message = ucfirst(str_replace('_', ' ', $message));
/*if ($arguments) {
$message .= ' (' . implode(', ', array_map($dumper, $arguments)) . ')';
}*/
}
return new $class($message, $innerException);
}
/**
* Retrieves error string given a message key for lookup
*
* @static
* @param string $messageKey
* @return string|false Returns the error string if found; FALSE otherwise
*/
public static function getExceptionMessage($messageKey)
{
if ( ! self::$_messages) {
// Lazy-init messages
self::$_messages = array(
'QueryException#nonUniqueResult' =>
"The query contains more than one result."
);
}
if (isset(self::$_messages[$messageKey])) {
return self::$_messages[$messageKey];
}
return false;
}
}
\ No newline at end of file
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common; namespace Doctrine\Common;
/** /**
...@@ -30,12 +30,12 @@ namespace Doctrine\Common; ...@@ -30,12 +30,12 @@ namespace Doctrine\Common;
* is also compatible with the underscore "_" namespace separator. * is also compatible with the underscore "_" namespace separator.
* *
* A recommended class loading setup for optimal performance looks as follows: * A recommended class loading setup for optimal performance looks as follows:
* *
* 1) Use a GlobalClassLoader. * 1) Use a GlobalClassLoader.
* 2) Reduce the include_path to only the path to the PEAR packages. * 2) Reduce the include_path to only the path to the PEAR packages.
* 2) Register the namespaces of any other (non-pear) class library with their * 2) Register the namespaces of any other (non-pear) class library with their
* absolute base paths, like this: $gcl->registerNamespace('Zend', '/path/to/zf-lib'); * absolute base paths, like this: $gcl->registerNamespace('Zend', '/path/to/zf-lib');
* *
* If no base path is configured for a certain namespace, the GlobalClassLoader relies on * If no base path is configured for a certain namespace, the GlobalClassLoader relies on
* the include_path. * the include_path.
* *
...@@ -46,7 +46,7 @@ namespace Doctrine\Common; ...@@ -46,7 +46,7 @@ namespace Doctrine\Common;
* @author Guilherme Blanco <guilhermeblanco@hotmail.com> * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
* *
* @deprecated Use Doctrine\Common\ClassLoader instead. * @deprecated Use Doctrine\Common\ClassLoader instead.
*/ */
class GlobalClassLoader class GlobalClassLoader
...@@ -55,26 +55,26 @@ class GlobalClassLoader ...@@ -55,26 +55,26 @@ class GlobalClassLoader
* @var string File extension used for classes * @var string File extension used for classes
*/ */
private $_defaultFileExtension = '.php'; private $_defaultFileExtension = '.php';
/** /**
* @var array The custom file extensions of class libraries. * @var array The custom file extensions of class libraries.
*/ */
private $_fileExtensions = array(); private $_fileExtensions = array();
/** /**
* @var array Hashmap of base paths to class libraries. * @var array Hashmap of base paths to class libraries.
*/ */
private $_basePaths = array(); private $_basePaths = array();
/** /**
* Installs this class loader on the SPL autoload stack as the only class loader. * Installs this class loader on the SPL autoload stack as the only class loader.
* *
* @throws DoctrineException If the SPL autoload stack already contains other autoloaders. * @throws Exception If the SPL autoload stack already contains other autoloaders.
*/ */
public function register() public function register()
{ {
if (spl_autoload_functions() !== false) { if (spl_autoload_functions() !== false) {
throw new DoctrineException("Autoload stack is not empty. GlobalClassLoader does not work " throw new CommonException("Autoload stack is not empty. GlobalClassLoader does not work "
. "in an autoload stack."); . "in an autoload stack.");
} }
spl_autoload_register(array($this, 'loadClass')); spl_autoload_register(array($this, 'loadClass'));
...@@ -83,7 +83,7 @@ class GlobalClassLoader ...@@ -83,7 +83,7 @@ class GlobalClassLoader
/** /**
* Sets the default file extension of class files. * Sets the default file extension of class files.
* *
* @param string $extension * @param string $extension
* @return void * @return void
*/ */
public function setDefaultFileExtension($extension) public function setDefaultFileExtension($extension)
...@@ -117,7 +117,7 @@ class GlobalClassLoader ...@@ -117,7 +117,7 @@ class GlobalClassLoader
{ {
$prefix = ''; $prefix = '';
$separator = '\\'; $separator = '\\';
if (($pos = strpos($className, $separator)) !== false) { if (($pos = strpos($className, $separator)) !== false) {
$prefix = substr($className, 0, strpos($className, $separator)); $prefix = substr($className, 0, strpos($className, $separator));
} else if (($pos = strpos($className, '_')) !== false) { } else if (($pos = strpos($className, '_')) !== false) {
...@@ -125,7 +125,7 @@ class GlobalClassLoader ...@@ -125,7 +125,7 @@ class GlobalClassLoader
$prefix = substr($className, 0, strpos($className, '_')); $prefix = substr($className, 0, strpos($className, '_'));
$separator = '_'; $separator = '_';
} }
require ((isset($this->_basePaths[$prefix])) ? $this->_basePaths[$prefix] . DIRECTORY_SEPARATOR : '') require ((isset($this->_basePaths[$prefix])) ? $this->_basePaths[$prefix] . DIRECTORY_SEPARATOR : '')
. str_replace($separator, DIRECTORY_SEPARATOR, $className) . str_replace($separator, DIRECTORY_SEPARATOR, $className)
. (isset($this->_fileExtensions[$prefix]) ? $this->_fileExtensions[$prefix] : $this->_defaultFileExtension); . (isset($this->_fileExtensions[$prefix]) ? $this->_fileExtensions[$prefix] : $this->_defaultFileExtension);
......
...@@ -409,7 +409,7 @@ class Connection ...@@ -409,7 +409,7 @@ class Connection
{ {
$this->_transactionIsolationLevel = $level; $this->_transactionIsolationLevel = $level;
return $this->executeUpdate($this->_platform->getSetTransactionIsolationSql($level)); return $this->executeUpdate($this->_platform->getSetTransactionIsolationSQL($level));
} }
/** /**
...@@ -493,7 +493,7 @@ class Connection ...@@ -493,7 +493,7 @@ class Connection
*/ */
public function setCharset($charset) public function setCharset($charset)
{ {
$this->executeUpdate($this->_platform->getSetCharsetSql($charset)); $this->executeUpdate($this->_platform->getSetCharsetSQL($charset));
} }
/** /**
......
...@@ -90,7 +90,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -90,7 +90,7 @@ class MsSqlPlatform extends AbstractPlatform
* @param TableDiff $diff * @param TableDiff $diff
* @return array * @return array
*/ */
public function getAlterTableSql(TableDiff $diff) public function getAlterTableSQL(TableDiff $diff)
{ {
$queryParts = array(); $queryParts = array();
if ($diff->newName !== false) { if ($diff->newName !== false) {
...@@ -98,7 +98,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -98,7 +98,7 @@ class MsSqlPlatform extends AbstractPlatform
} }
foreach ($diff->addedColumns AS $fieldName => $column) { foreach ($diff->addedColumns AS $fieldName => $column) {
$queryParts[] = 'ADD ' . $this->getColumnDeclarationSql($column->getName(), $column->toArray()); $queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
} }
foreach ($diff->removedColumns AS $column) { foreach ($diff->removedColumns AS $column) {
...@@ -109,19 +109,19 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -109,19 +109,19 @@ class MsSqlPlatform extends AbstractPlatform
/* @var $columnDiff Doctrine\DBAL\Schema\ColumnDiff */ /* @var $columnDiff Doctrine\DBAL\Schema\ColumnDiff */
$column = $columnDiff->column; $column = $columnDiff->column;
$queryParts[] = 'CHANGE ' . ($columnDiff->oldColumnName) . ' ' $queryParts[] = 'CHANGE ' . ($columnDiff->oldColumnName) . ' '
. $this->getColumnDeclarationSql($column->getName(), $column->toArray()); . $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
} }
foreach ($diff->renamedColumns AS $oldColumnName => $column) { foreach ($diff->renamedColumns AS $oldColumnName => $column) {
$queryParts[] = 'CHANGE ' . $oldColumnName . ' ' $queryParts[] = 'CHANGE ' . $oldColumnName . ' '
. $this->getColumnDeclarationSql($column->getName(), $column->toArray()); . $this->getColumnDeclarationSQL($column->getName(), $column->toArray());
} }
$sql = array(); $sql = array();
if (count($queryParts) > 0) { if (count($queryParts) > 0) {
$sql[] = 'ALTER TABLE ' . $diff->name . ' ' . implode(", ", $queryParts); $sql[] = 'ALTER TABLE ' . $diff->name . ' ' . implode(", ", $queryParts);
} }
$sql = array_merge($sql, $this->_getAlterTableIndexForeignKeySql($diff)); $sql = array_merge($sql, $this->_getAlterTableIndexForeignKeySQL($diff));
return $sql; return $sql;
} }
...@@ -233,12 +233,12 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -233,12 +233,12 @@ class MsSqlPlatform extends AbstractPlatform
return false; return false;
} }
public function getShowDatabasesSql() public function getShowDatabasesSQL()
{ {
return 'SHOW DATABASES'; return 'SHOW DATABASES';
} }
public function getListTablesSql() public function getListTablesSQL()
{ {
return 'SHOW TABLES'; return 'SHOW TABLES';
} }
...@@ -250,7 +250,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -250,7 +250,7 @@ class MsSqlPlatform extends AbstractPlatform
* @return string * @return string
* @override * @override
*/ */
public function getCreateDatabaseSql($name) public function getCreateDatabaseSQL($name)
{ {
return 'CREATE DATABASE ' . $name; return 'CREATE DATABASE ' . $name;
} }
...@@ -262,41 +262,41 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -262,41 +262,41 @@ class MsSqlPlatform extends AbstractPlatform
* @return string * @return string
* @override * @override
*/ */
public function getDropDatabaseSql($name) public function getDropDatabaseSQL($name)
{ {
return 'DROP DATABASE ' . $name; return 'DROP DATABASE ' . $name;
} }
public function getSetTransactionIsolationSql($level) public function getSetTransactionIsolationSQL($level)
{ {
return 'SET TRANSACTION ISOLATION LEVEL ' . $this->_getTransactionIsolationLevelSql($level); return 'SET TRANSACTION ISOLATION LEVEL ' . $this->_getTransactionIsolationLevelSQL($level);
} }
/** /**
* @override * @override
*/ */
public function getIntegerTypeDeclarationSql(array $field) public function getIntegerTypeDeclarationSQL(array $field)
{ {
return 'INT' . $this->_getCommonIntegerTypeDeclarationSql($field); return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
/** /**
* @override * @override
*/ */
public function getBigIntTypeDeclarationSql(array $field) public function getBigIntTypeDeclarationSQL(array $field)
{ {
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSql($field); return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
/** /**
* @override * @override
*/ */
public function getSmallIntTypeDeclarationSql(array $field) public function getSmallIntTypeDeclarationSQL(array $field)
{ {
return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSql($field); return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
public function getVarcharTypeDeclarationSql(array $field) public function getVarcharTypeDeclarationSQL(array $field)
{ {
if ( ! isset($field['length'])) { if ( ! isset($field['length'])) {
if (array_key_exists('default', $field)) { if (array_key_exists('default', $field)) {
...@@ -314,7 +314,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -314,7 +314,7 @@ class MsSqlPlatform extends AbstractPlatform
} }
/** @override */ /** @override */
public function getClobTypeDeclarationSql(array $field) public function getClobTypeDeclarationSQL(array $field)
{ {
return 'TEXT'; return 'TEXT';
} }
...@@ -322,7 +322,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -322,7 +322,7 @@ class MsSqlPlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
protected function _getCommonIntegerTypeDeclarationSql(array $columnDef) protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
{ {
$autoinc = ''; $autoinc = '';
if ( ! empty($columnDef['autoincrement'])) { if ( ! empty($columnDef['autoincrement'])) {
...@@ -336,7 +336,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -336,7 +336,7 @@ class MsSqlPlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getDateTimeTypeDeclarationSql(array $fieldDeclaration) public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'CHAR(' . strlen('YYYY-MM-DD HH:MM:SS') . ')'; return 'CHAR(' . strlen('YYYY-MM-DD HH:MM:SS') . ')';
} }
...@@ -344,7 +344,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -344,7 +344,7 @@ class MsSqlPlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getDateTypeDeclarationSql(array $fieldDeclaration) public function getDateTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'CHAR(' . strlen('YYYY-MM-DD') . ')'; return 'CHAR(' . strlen('YYYY-MM-DD') . ')';
} }
...@@ -352,7 +352,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -352,7 +352,7 @@ class MsSqlPlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getTimeTypeDeclarationSql(array $fieldDeclaration) public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'CHAR(' . strlen('HH:MM:SS') . ')'; return 'CHAR(' . strlen('HH:MM:SS') . ')';
} }
...@@ -360,7 +360,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -360,7 +360,7 @@ class MsSqlPlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getBooleanTypeDeclarationSql(array $field) public function getBooleanTypeDeclarationSQL(array $field)
{ {
return 'BIT'; return 'BIT';
} }
...@@ -470,7 +470,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -470,7 +470,7 @@ class MsSqlPlatform extends AbstractPlatform
* @param string $identifierColumnName * @param string $identifierColumnName
* @return string $sql * @return string $sql
*/ */
public function getEmptyIdentityInsertSql($quotedTableName, $quotedIdentifierColumnName) public function getEmptyIdentityInsertSQL($quotedTableName, $quotedIdentifierColumnName)
{ {
return 'INSERT INTO ' . $quotedTableName . ' DEFAULT VALUES'; return 'INSERT INTO ' . $quotedTableName . ' DEFAULT VALUES';
} }
...@@ -478,7 +478,7 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -478,7 +478,7 @@ class MsSqlPlatform extends AbstractPlatform
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function getTruncateTableSql($tableName, $cascade = false) public function getTruncateTableSQL($tableName, $cascade = false)
{ {
return 'TRUNCATE TABLE '.$tableName; return 'TRUNCATE TABLE '.$tableName;
} }
......
...@@ -126,7 +126,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -126,7 +126,7 @@ class SqlitePlatform extends AbstractPlatform
} }
} }
protected function _getTransactionIsolationLevelSql($level) protected function _getTransactionIsolationLevelSQL($level)
{ {
switch ($level) { switch ($level) {
case \Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED: case \Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED:
...@@ -136,13 +136,13 @@ class SqlitePlatform extends AbstractPlatform ...@@ -136,13 +136,13 @@ class SqlitePlatform extends AbstractPlatform
case \Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE: case \Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE:
return 1; return 1;
default: default:
return parent::_getTransactionIsolationLevelSql($level); return parent::_getTransactionIsolationLevelSQL($level);
} }
} }
public function getSetTransactionIsolationSql($level) public function getSetTransactionIsolationSQL($level)
{ {
return 'PRAGMA read_uncommitted = ' . $this->_getTransactionIsolationLevelSql($level); return 'PRAGMA read_uncommitted = ' . $this->_getTransactionIsolationLevelSQL($level);
} }
/** /**
...@@ -156,7 +156,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -156,7 +156,7 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getBooleanTypeDeclarationSql(array $field) public function getBooleanTypeDeclarationSQL(array $field)
{ {
return 'BOOLEAN'; return 'BOOLEAN';
} }
...@@ -164,17 +164,17 @@ class SqlitePlatform extends AbstractPlatform ...@@ -164,17 +164,17 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getIntegerTypeDeclarationSql(array $field) public function getIntegerTypeDeclarationSQL(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
/** /**
* @override * @override
*/ */
public function getBigIntTypeDeclarationSql(array $field) public function getBigIntTypeDeclarationSQL(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
/** /**
...@@ -182,15 +182,15 @@ class SqlitePlatform extends AbstractPlatform ...@@ -182,15 +182,15 @@ class SqlitePlatform extends AbstractPlatform
*/ */
public function getTinyIntTypeDeclarationSql(array $field) public function getTinyIntTypeDeclarationSql(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
/** /**
* @override * @override
*/ */
public function getSmallIntTypeDeclarationSql(array $field) public function getSmallIntTypeDeclarationSQL(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
/** /**
...@@ -198,13 +198,13 @@ class SqlitePlatform extends AbstractPlatform ...@@ -198,13 +198,13 @@ class SqlitePlatform extends AbstractPlatform
*/ */
public function getMediumIntTypeDeclarationSql(array $field) public function getMediumIntTypeDeclarationSql(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSQL($field);
} }
/** /**
* @override * @override
*/ */
public function getDateTimeTypeDeclarationSql(array $fieldDeclaration) public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'DATETIME'; return 'DATETIME';
} }
...@@ -212,7 +212,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -212,7 +212,7 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getDateTypeDeclarationSql(array $fieldDeclaration) public function getDateTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'DATE'; return 'DATE';
} }
...@@ -220,7 +220,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -220,7 +220,7 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
public function getTimeTypeDeclarationSql(array $fieldDeclaration) public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
{ {
return 'TIME'; return 'TIME';
} }
...@@ -228,7 +228,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -228,7 +228,7 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* @override * @override
*/ */
protected function _getCommonIntegerTypeDeclarationSql(array $columnDef) protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
{ {
$autoinc = ! empty($columnDef['autoincrement']) ? ' AUTOINCREMENT' : ''; $autoinc = ! empty($columnDef['autoincrement']) ? ' AUTOINCREMENT' : '';
$pk = ! empty($columnDef['primary']) && ! empty($autoinc) ? ' PRIMARY KEY' : ''; $pk = ! empty($columnDef['primary']) && ! empty($autoinc) ? ' PRIMARY KEY' : '';
...@@ -265,9 +265,9 @@ class SqlitePlatform extends AbstractPlatform ...@@ -265,9 +265,9 @@ class SqlitePlatform extends AbstractPlatform
* @return void * @return void
* @override * @override
*/ */
protected function _getCreateTableSql($name, array $columns, array $options = array()) protected function _getCreateTableSQL($name, array $columns, array $options = array())
{ {
$queryFields = $this->getColumnDeclarationListSql($columns); $queryFields = $this->getColumnDeclarationListSQL($columns);
$autoinc = false; $autoinc = false;
foreach($columns as $field) { foreach($columns as $field) {
...@@ -287,12 +287,12 @@ class SqlitePlatform extends AbstractPlatform ...@@ -287,12 +287,12 @@ class SqlitePlatform extends AbstractPlatform
if (isset($options['indexes']) && ! empty($options['indexes'])) { if (isset($options['indexes']) && ! empty($options['indexes'])) {
foreach ($options['indexes'] as $index => $indexDef) { foreach ($options['indexes'] as $index => $indexDef) {
$query[] = $this->getCreateIndexSql($indexDef, $name); $query[] = $this->getCreateIndexSQL($indexDef, $name);
} }
} }
if (isset($options['unique']) && ! empty($options['unique'])) { if (isset($options['unique']) && ! empty($options['unique'])) {
foreach ($options['unique'] as $index => $indexDef) { foreach ($options['unique'] as $index => $indexDef) {
$query[] = $this->getCreateIndexSql($indexDef, $name); $query[] = $this->getCreateIndexSQL($indexDef, $name);
} }
} }
return $query; return $query;
...@@ -301,7 +301,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -301,7 +301,7 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getVarcharTypeDeclarationSql(array $field) public function getVarcharTypeDeclarationSQL(array $field)
{ {
if ( ! isset($field['length'])) { if ( ! isset($field['length'])) {
if (array_key_exists('default', $field)) { if (array_key_exists('default', $field)) {
...@@ -317,44 +317,44 @@ class SqlitePlatform extends AbstractPlatform ...@@ -317,44 +317,44 @@ class SqlitePlatform extends AbstractPlatform
: ($length ? 'VARCHAR(' . $length . ')' : 'TEXT'); : ($length ? 'VARCHAR(' . $length . ')' : 'TEXT');
} }
public function getClobTypeDeclarationSql(array $field) public function getClobTypeDeclarationSQL(array $field)
{ {
return 'CLOB'; return 'CLOB';
} }
public function getListTableConstraintsSql($table) public function getListTableConstraintsSQL($table)
{ {
return "SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name = '$table' AND sql NOT NULL ORDER BY name"; return "SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name = '$table' AND sql NOT NULL ORDER BY name";
} }
public function getListTableColumnsSql($table) public function getListTableColumnsSQL($table)
{ {
return "PRAGMA table_info($table)"; return "PRAGMA table_info($table)";
} }
public function getListTableIndexesSql($table) public function getListTableIndexesSQL($table)
{ {
return "PRAGMA index_list($table)"; return "PRAGMA index_list($table)";
} }
public function getListTablesSql() public function getListTablesSQL()
{ {
return "SELECT name FROM sqlite_master WHERE type = 'table' AND name != 'sqlite_sequence' " return "SELECT name FROM sqlite_master WHERE type = 'table' AND name != 'sqlite_sequence' "
. "UNION ALL SELECT name FROM sqlite_temp_master " . "UNION ALL SELECT name FROM sqlite_temp_master "
. "WHERE type = 'table' ORDER BY name"; . "WHERE type = 'table' ORDER BY name";
} }
public function getListViewsSql($database) public function getListViewsSQL($database)
{ {
return "SELECT name, sql FROM sqlite_master WHERE type='view' AND sql NOT NULL"; return "SELECT name, sql FROM sqlite_master WHERE type='view' AND sql NOT NULL";
} }
public function getCreateViewSql($name, $sql) public function getCreateViewSQL($name, $sql)
{ {
return 'CREATE VIEW ' . $name . ' AS ' . $sql; return 'CREATE VIEW ' . $name . ' AS ' . $sql;
} }
public function getDropViewSql($name) public function getDropViewSQL($name)
{ {
return 'DROP VIEW '. $name; return 'DROP VIEW '. $name;
} }
...@@ -390,7 +390,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -390,7 +390,7 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function getTruncateTableSql($tableName, $cascade = false) public function getTruncateTableSQL($tableName, $cascade = false)
{ {
return 'DELETE FROM '.$tableName; return 'DELETE FROM '.$tableName;
} }
......
...@@ -108,7 +108,7 @@ abstract class AbstractSchemaManager ...@@ -108,7 +108,7 @@ abstract class AbstractSchemaManager
*/ */
public function listDatabases() public function listDatabases()
{ {
$sql = $this->_platform->getListDatabasesSql(); $sql = $this->_platform->getListDatabasesSQL();
$databases = $this->_conn->fetchAll($sql); $databases = $this->_conn->fetchAll($sql);
...@@ -125,7 +125,7 @@ abstract class AbstractSchemaManager ...@@ -125,7 +125,7 @@ abstract class AbstractSchemaManager
if (is_null($database)) { if (is_null($database)) {
$database = $this->_conn->getDatabase(); $database = $this->_conn->getDatabase();
} }
$sql = $this->_platform->getListSequencesSql($database); $sql = $this->_platform->getListSequencesSQL($database);
$sequences = $this->_conn->fetchAll($sql); $sequences = $this->_conn->fetchAll($sql);
...@@ -147,7 +147,7 @@ abstract class AbstractSchemaManager ...@@ -147,7 +147,7 @@ abstract class AbstractSchemaManager
*/ */
public function listTableColumns($table) public function listTableColumns($table)
{ {
$sql = $this->_platform->getListTableColumnsSql($table); $sql = $this->_platform->getListTableColumnsSQL($table);
$tableColumns = $this->_conn->fetchAll($sql); $tableColumns = $this->_conn->fetchAll($sql);
...@@ -164,7 +164,7 @@ abstract class AbstractSchemaManager ...@@ -164,7 +164,7 @@ abstract class AbstractSchemaManager
*/ */
public function listTableIndexes($table) public function listTableIndexes($table)
{ {
$sql = $this->_platform->getListTableIndexesSql($table); $sql = $this->_platform->getListTableIndexesSQL($table);
$tableIndexes = $this->_conn->fetchAll($sql); $tableIndexes = $this->_conn->fetchAll($sql);
...@@ -178,7 +178,7 @@ abstract class AbstractSchemaManager ...@@ -178,7 +178,7 @@ abstract class AbstractSchemaManager
*/ */
public function listTableNames() public function listTableNames()
{ {
$sql = $this->_platform->getListTablesSql(); $sql = $this->_platform->getListTablesSQL();
$tables = $this->_conn->fetchAll($sql); $tables = $this->_conn->fetchAll($sql);
...@@ -233,7 +233,7 @@ abstract class AbstractSchemaManager ...@@ -233,7 +233,7 @@ abstract class AbstractSchemaManager
public function listViews() public function listViews()
{ {
$database = $this->_conn->getDatabase(); $database = $this->_conn->getDatabase();
$sql = $this->_platform->getListViewsSql($database); $sql = $this->_platform->getListViewsSQL($database);
$views = $this->_conn->fetchAll($sql); $views = $this->_conn->fetchAll($sql);
return $this->_getPortableViewsList($views); return $this->_getPortableViewsList($views);
...@@ -250,7 +250,7 @@ abstract class AbstractSchemaManager ...@@ -250,7 +250,7 @@ abstract class AbstractSchemaManager
if (is_null($database)) { if (is_null($database)) {
$database = $this->_conn->getDatabase(); $database = $this->_conn->getDatabase();
} }
$sql = $this->_platform->getListTableForeignKeysSql($table, $database); $sql = $this->_platform->getListTableForeignKeysSQL($table, $database);
$tableForeignKeys = $this->_conn->fetchAll($sql); $tableForeignKeys = $this->_conn->fetchAll($sql);
return $this->_getPortableTableForeignKeysList($tableForeignKeys); return $this->_getPortableTableForeignKeysList($tableForeignKeys);
...@@ -267,7 +267,7 @@ abstract class AbstractSchemaManager ...@@ -267,7 +267,7 @@ abstract class AbstractSchemaManager
*/ */
public function dropDatabase($database) public function dropDatabase($database)
{ {
$this->_execSql($this->_platform->getDropDatabaseSql($database)); $this->_execSql($this->_platform->getDropDatabaseSQL($database));
} }
/** /**
...@@ -277,7 +277,7 @@ abstract class AbstractSchemaManager ...@@ -277,7 +277,7 @@ abstract class AbstractSchemaManager
*/ */
public function dropTable($table) public function dropTable($table)
{ {
$this->_execSql($this->_platform->getDropTableSql($table)); $this->_execSql($this->_platform->getDropTableSQL($table));
} }
/** /**
...@@ -292,7 +292,7 @@ abstract class AbstractSchemaManager ...@@ -292,7 +292,7 @@ abstract class AbstractSchemaManager
$index = $index->getName(); $index = $index->getName();
} }
$this->_execSql($this->_platform->getDropIndexSql($index, $table)); $this->_execSql($this->_platform->getDropIndexSQL($index, $table));
} }
/** /**
...@@ -303,7 +303,7 @@ abstract class AbstractSchemaManager ...@@ -303,7 +303,7 @@ abstract class AbstractSchemaManager
*/ */
public function dropConstraint(Constraint $constraint, $table) public function dropConstraint(Constraint $constraint, $table)
{ {
$this->_execSql($this->_platform->getDropConstraintSql($constraint, $table)); $this->_execSql($this->_platform->getDropConstraintSQL($constraint, $table));
} }
/** /**
...@@ -315,7 +315,7 @@ abstract class AbstractSchemaManager ...@@ -315,7 +315,7 @@ abstract class AbstractSchemaManager
*/ */
public function dropForeignKey($foreignKey, $table) public function dropForeignKey($foreignKey, $table)
{ {
$this->_execSql($this->_platform->getDropForeignKeySql($foreignKey, $table)); $this->_execSql($this->_platform->getDropForeignKeySQL($foreignKey, $table));
} }
/** /**
...@@ -325,7 +325,7 @@ abstract class AbstractSchemaManager ...@@ -325,7 +325,7 @@ abstract class AbstractSchemaManager
*/ */
public function dropSequence($name) public function dropSequence($name)
{ {
$this->_execSql($this->_platform->getDropSequenceSql($name)); $this->_execSql($this->_platform->getDropSequenceSQL($name));
} }
/** /**
...@@ -336,7 +336,7 @@ abstract class AbstractSchemaManager ...@@ -336,7 +336,7 @@ abstract class AbstractSchemaManager
*/ */
public function dropView($name) public function dropView($name)
{ {
$this->_execSql($this->_platform->getDropViewSql($name)); $this->_execSql($this->_platform->getDropViewSQL($name));
} }
/* create*() Methods */ /* create*() Methods */
...@@ -348,7 +348,7 @@ abstract class AbstractSchemaManager ...@@ -348,7 +348,7 @@ abstract class AbstractSchemaManager
*/ */
public function createDatabase($database) public function createDatabase($database)
{ {
$this->_execSql($this->_platform->getCreateDatabaseSql($database)); $this->_execSql($this->_platform->getCreateDatabaseSQL($database));
} }
/** /**
...@@ -360,7 +360,7 @@ abstract class AbstractSchemaManager ...@@ -360,7 +360,7 @@ abstract class AbstractSchemaManager
public function createTable(Table $table) public function createTable(Table $table)
{ {
$createFlags = AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS; $createFlags = AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS;
$this->_execSql($this->_platform->getCreateTableSql($table, $createFlags)); $this->_execSql($this->_platform->getCreateTableSQL($table, $createFlags));
} }
/** /**
...@@ -371,7 +371,7 @@ abstract class AbstractSchemaManager ...@@ -371,7 +371,7 @@ abstract class AbstractSchemaManager
*/ */
public function createSequence($sequence) public function createSequence($sequence)
{ {
$this->_execSql($this->_platform->getCreateSequenceSql($sequence)); $this->_execSql($this->_platform->getCreateSequenceSQL($sequence));
} }
/** /**
...@@ -382,7 +382,7 @@ abstract class AbstractSchemaManager ...@@ -382,7 +382,7 @@ abstract class AbstractSchemaManager
*/ */
public function createConstraint(Constraint $constraint, $table) public function createConstraint(Constraint $constraint, $table)
{ {
$this->_execSql($this->_platform->getCreateConstraintSql($constraint, $table)); $this->_execSql($this->_platform->getCreateConstraintSQL($constraint, $table));
} }
/** /**
...@@ -393,7 +393,7 @@ abstract class AbstractSchemaManager ...@@ -393,7 +393,7 @@ abstract class AbstractSchemaManager
*/ */
public function createIndex(Index $index, $table) public function createIndex(Index $index, $table)
{ {
$this->_execSql($this->_platform->getCreateIndexSql($index, $table)); $this->_execSql($this->_platform->getCreateIndexSQL($index, $table));
} }
/** /**
...@@ -404,7 +404,7 @@ abstract class AbstractSchemaManager ...@@ -404,7 +404,7 @@ abstract class AbstractSchemaManager
*/ */
public function createForeignKey(ForeignKeyConstraint $foreignKey, $table) public function createForeignKey(ForeignKeyConstraint $foreignKey, $table)
{ {
$this->_execSql($this->_platform->getCreateForeignKeySql($foreignKey, $table)); $this->_execSql($this->_platform->getCreateForeignKeySQL($foreignKey, $table));
} }
/** /**
...@@ -414,7 +414,7 @@ abstract class AbstractSchemaManager ...@@ -414,7 +414,7 @@ abstract class AbstractSchemaManager
*/ */
public function createView(View $view) public function createView(View $view)
{ {
$this->_execSql($this->_platform->getCreateViewSql($view->getName(), $view->getSql())); $this->_execSql($this->_platform->getCreateViewSQL($view->getName(), $view->getSql()));
} }
/* dropAndCreate*() Methods */ /* dropAndCreate*() Methods */
...@@ -511,7 +511,7 @@ abstract class AbstractSchemaManager ...@@ -511,7 +511,7 @@ abstract class AbstractSchemaManager
*/ */
public function alterTable(TableDiff $tableDiff) public function alterTable(TableDiff $tableDiff)
{ {
$queries = $this->_platform->getAlterTableSql($tableDiff); $queries = $this->_platform->getAlterTableSQL($tableDiff);
if (is_array($queries) && count($queries)) { if (is_array($queries) && count($queries)) {
foreach ($queries AS $ddlQuery) { foreach ($queries AS $ddlQuery) {
$this->_execSql($ddlQuery); $this->_execSql($ddlQuery);
......
...@@ -31,7 +31,7 @@ namespace Doctrine\DBAL\Schema; ...@@ -31,7 +31,7 @@ namespace Doctrine\DBAL\Schema;
* @since 2.0 * @since 2.0
*/ */
class MsSqlSchemaManager extends AbstractSchemaManager class MsSqlSchemaManager extends AbstractSchemaManager
{ {
/** /**
* create a new database * create a new database
* *
...@@ -160,7 +160,7 @@ class MsSqlSchemaManager extends AbstractSchemaManager ...@@ -160,7 +160,7 @@ class MsSqlSchemaManager extends AbstractSchemaManager
case 'rename': case 'rename':
case 'change': case 'change':
default: default:
throw \Doctrine\Common\DoctrineException::alterTableChangeNotSupported($changeName); throw SchemaException::alterTableChangeNotSupported($changeName);
} }
} }
...@@ -225,7 +225,7 @@ class MsSqlSchemaManager extends AbstractSchemaManager ...@@ -225,7 +225,7 @@ class MsSqlSchemaManager extends AbstractSchemaManager
{ {
return 'DROP TABLE ' . $seqName; return 'DROP TABLE ' . $seqName;
} }
/** /**
* lists all database sequences * lists all database sequences
* *
......
...@@ -128,42 +128,42 @@ class SchemaDiff ...@@ -128,42 +128,42 @@ class SchemaDiff
if ($platform->supportsForeignKeyConstraints() && $saveMode == false) { if ($platform->supportsForeignKeyConstraints() && $saveMode == false) {
foreach ($this->orphanedForeignKeys AS $orphanedForeignKey) { foreach ($this->orphanedForeignKeys AS $orphanedForeignKey) {
$sql[] = $platform->getDropForeignKeySql($orphanedForeignKey, $orphanedForeignKey->getLocalTableName()); $sql[] = $platform->getDropForeignKeySQL($orphanedForeignKey, $orphanedForeignKey->getLocalTableName());
} }
} }
if ($platform->supportsSequences() == true) { if ($platform->supportsSequences() == true) {
foreach ($this->changedSequences AS $sequence) { foreach ($this->changedSequences AS $sequence) {
$sql[] = $platform->getDropSequenceSql($sequence); $sql[] = $platform->getDropSequenceSQL($sequence);
$sql[] = $platform->getCreateSequenceSql($sequence); $sql[] = $platform->getCreateSequenceSQL($sequence);
} }
if ($saveMode === false) { if ($saveMode === false) {
foreach ($this->removedSequences AS $sequence) { foreach ($this->removedSequences AS $sequence) {
$sql[] = $platform->getDropSequenceSql($sequence); $sql[] = $platform->getDropSequenceSQL($sequence);
} }
} }
foreach ($this->newSequences AS $sequence) { foreach ($this->newSequences AS $sequence) {
$sql[] = $platform->getCreateSequenceSql($sequence); $sql[] = $platform->getCreateSequenceSQL($sequence);
} }
} }
foreach ($this->newTables AS $table) { foreach ($this->newTables AS $table) {
$sql = array_merge( $sql = array_merge(
$sql, $sql,
$platform->getCreateTableSql($table, AbstractPlatform::CREATE_FOREIGNKEYS|AbstractPlatform::CREATE_INDEXES) $platform->getCreateTableSQL($table, AbstractPlatform::CREATE_FOREIGNKEYS|AbstractPlatform::CREATE_INDEXES)
); );
} }
if ($saveMode === false) { if ($saveMode === false) {
foreach ($this->removedTables AS $table) { foreach ($this->removedTables AS $table) {
$sql[] = $platform->getDropTableSql($table); $sql[] = $platform->getDropTableSQL($table);
} }
} }
foreach ($this->changedTables AS $tableDiff) { foreach ($this->changedTables AS $tableDiff) {
$sql = array_merge($sql, $platform->getAlterTableSql($tableDiff)); $sql = array_merge($sql, $platform->getAlterTableSQL($tableDiff));
} }
return $sql; return $sql;
......
...@@ -119,4 +119,8 @@ class SchemaException extends \Doctrine\DBAL\DBALException ...@@ -119,4 +119,8 @@ class SchemaException extends \Doctrine\DBAL\DBALException
"unnamed." "unnamed."
); );
} }
static public function alterTableChangeNotSupported($changeName) {
return new self ("Alter table change not supported, given '$changeName'");
}
} }
\ No newline at end of file
...@@ -77,7 +77,7 @@ class CreateSchemaSqlCollector implements Visitor ...@@ -77,7 +77,7 @@ class CreateSchemaSqlCollector implements Visitor
public function acceptTable(Table $table) public function acceptTable(Table $table)
{ {
$this->_createTableQueries = array_merge($this->_createTableQueries, $this->_createTableQueries = array_merge($this->_createTableQueries,
$this->_platform->getCreateTableSql($table) $this->_platform->getCreateTableSQL($table)
); );
} }
...@@ -95,7 +95,7 @@ class CreateSchemaSqlCollector implements Visitor ...@@ -95,7 +95,7 @@ class CreateSchemaSqlCollector implements Visitor
// Append the foreign key constraints SQL // Append the foreign key constraints SQL
if ($this->_platform->supportsForeignKeyConstraints()) { if ($this->_platform->supportsForeignKeyConstraints()) {
$this->_createFkConstraintQueries = array_merge($this->_createFkConstraintQueries, $this->_createFkConstraintQueries = array_merge($this->_createFkConstraintQueries,
(array) $this->_platform->getCreateForeignKeySql($fkConstraint, $localTable->getName()) (array) $this->_platform->getCreateForeignKeySQL($fkConstraint, $localTable->getName())
); );
} }
} }
...@@ -115,7 +115,7 @@ class CreateSchemaSqlCollector implements Visitor ...@@ -115,7 +115,7 @@ class CreateSchemaSqlCollector implements Visitor
public function acceptSequence(Sequence $sequence) public function acceptSequence(Sequence $sequence)
{ {
$this->_createSequenceQueries = array_merge( $this->_createSequenceQueries = array_merge(
$this->_createSequenceQueries, (array)$this->_platform->getCreateSequenceSql($sequence) $this->_createSequenceQueries, (array)$this->_platform->getCreateSequenceSQL($sequence)
); );
} }
......
...@@ -83,7 +83,7 @@ class DropSchemaSqlCollector implements Visitor ...@@ -83,7 +83,7 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function acceptTable(Table $table) public function acceptTable(Table $table)
{ {
$this->_tables[] = $this->_platform->getDropTableSql($table->getName()); $this->_tables[] = $this->_platform->getDropTableSQL($table->getName());
} }
/** /**
...@@ -104,7 +104,7 @@ class DropSchemaSqlCollector implements Visitor ...@@ -104,7 +104,7 @@ class DropSchemaSqlCollector implements Visitor
throw SchemaException::namedForeignKeyRequired($localTable, $fkConstraint); throw SchemaException::namedForeignKeyRequired($localTable, $fkConstraint);
} }
$this->_constraints[] = $this->_platform->getDropForeignKeySql($fkConstraint->getName(), $localTable->getName()); $this->_constraints[] = $this->_platform->getDropForeignKeySQL($fkConstraint->getName(), $localTable->getName());
} }
/** /**
...@@ -121,7 +121,7 @@ class DropSchemaSqlCollector implements Visitor ...@@ -121,7 +121,7 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function acceptSequence(Sequence $sequence) public function acceptSequence(Sequence $sequence)
{ {
$this->_sequences[] = $this->_platform->getDropSequenceSql($sequence->getName()); $this->_sequences[] = $this->_platform->getDropSequenceSQL($sequence->getName());
} }
/** /**
......
...@@ -11,7 +11,7 @@ class ArrayType extends Type ...@@ -11,7 +11,7 @@ class ArrayType extends Type
{ {
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getClobTypeDeclarationSql($fieldDeclaration); return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToDatabaseValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function convertToDatabaseValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
......
...@@ -17,7 +17,7 @@ class BigIntType extends Type ...@@ -17,7 +17,7 @@ class BigIntType extends Type
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getBigIntTypeDeclarationSql($fieldDeclaration); return $platform->getBigIntTypeDeclarationSQL($fieldDeclaration);
} }
public function getTypeCode() public function getTypeCode()
......
...@@ -13,7 +13,7 @@ class BooleanType extends Type ...@@ -13,7 +13,7 @@ class BooleanType extends Type
{ {
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{ {
return $platform->getBooleanTypeDeclarationSql($fieldDeclaration); return $platform->getBooleanTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToDatabaseValue($value, AbstractPlatform $platform) public function convertToDatabaseValue($value, AbstractPlatform $platform)
......
...@@ -18,7 +18,7 @@ class DateTimeType extends Type ...@@ -18,7 +18,7 @@ class DateTimeType extends Type
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{ {
return $platform->getDateTimeTypeDeclarationSql($fieldDeclaration); return $platform->getDateTimeTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToDatabaseValue($value, AbstractPlatform $platform) public function convertToDatabaseValue($value, AbstractPlatform $platform)
......
...@@ -18,7 +18,7 @@ class DateType extends Type ...@@ -18,7 +18,7 @@ class DateType extends Type
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{ {
return $platform->getDateTypeDeclarationSql($fieldDeclaration); return $platform->getDateTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToDatabaseValue($value, AbstractPlatform $platform) public function convertToDatabaseValue($value, AbstractPlatform $platform)
......
...@@ -16,7 +16,7 @@ class DecimalType extends Type ...@@ -16,7 +16,7 @@ class DecimalType extends Type
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getDecimalTypeDeclarationSql($fieldDeclaration); return $platform->getDecimalTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
......
...@@ -17,7 +17,7 @@ class IntegerType extends Type ...@@ -17,7 +17,7 @@ class IntegerType extends Type
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getIntegerTypeDeclarationSql($fieldDeclaration); return $platform->getIntegerTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
......
...@@ -11,7 +11,7 @@ class ObjectType extends Type ...@@ -11,7 +11,7 @@ class ObjectType extends Type
{ {
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getClobTypeDeclarationSql($fieldDeclaration); return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToDatabaseValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function convertToDatabaseValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
......
...@@ -16,7 +16,7 @@ class SmallIntType extends Type ...@@ -16,7 +16,7 @@ class SmallIntType extends Type
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getSmallIntTypeDeclarationSql($fieldDeclaration); return $platform->getSmallIntTypeDeclarationSQL($fieldDeclaration);
} }
public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
......
...@@ -12,7 +12,7 @@ class StringType extends Type ...@@ -12,7 +12,7 @@ class StringType extends Type
/** @override */ /** @override */
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getVarcharTypeDeclarationSql($fieldDeclaration); return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
} }
/** @override */ /** @override */
......
...@@ -12,7 +12,7 @@ class TextType extends Type ...@@ -12,7 +12,7 @@ class TextType extends Type
/** @override */ /** @override */
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
return $platform->getClobTypeDeclarationSql($fieldDeclaration); return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
} }
public function getName() public function getName()
......
...@@ -21,7 +21,7 @@ class TimeType extends Type ...@@ -21,7 +21,7 @@ class TimeType extends Type
*/ */
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{ {
return $platform->getTimeTypeDeclarationSql($fieldDeclaration); return $platform->getTimeTypeDeclarationSQL($fieldDeclaration);
} }
/** /**
......
...@@ -2,15 +2,14 @@ ...@@ -2,15 +2,14 @@
namespace Doctrine\DBAL\Types; namespace Doctrine\DBAL\Types;
use Doctrine\Common\DoctrineException; use Doctrine\DBAL\Platforms\AbstractPlatform,
use Doctrine\DBAL\Platforms\AbstractPlatform; Doctrine\DBAL\DBALException;
use Doctrine\DBAL\DBALException;
/** /**
* The base class for so-called Doctrine mapping types. * The base class for so-called Doctrine mapping types.
* *
* A Type object is obtained by calling the static {@link getType()} method. * A Type object is obtained by calling the static {@link getType()} method.
* *
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
* @since 2.0 * @since 2.0
*/ */
...@@ -24,10 +23,10 @@ abstract class Type ...@@ -24,10 +23,10 @@ abstract class Type
const CODE_INT = 1; const CODE_INT = 1;
const CODE_STR = 2; const CODE_STR = 2;
const CODE_LOB = 3; const CODE_LOB = 3;
/** Map of already instantiated type objects. One instance per type (flyweight). */ /** Map of already instantiated type objects. One instance per type (flyweight). */
private static $_typeObjects = array(); private static $_typeObjects = array();
/** The map of supported doctrine mapping types. */ /** The map of supported doctrine mapping types. */
private static $_typesMap = array( private static $_typesMap = array(
'array' => 'Doctrine\DBAL\Types\ArrayType', 'array' => 'Doctrine\DBAL\Types\ArrayType',
...@@ -45,10 +44,10 @@ abstract class Type ...@@ -45,10 +44,10 @@ abstract class Type
'decimal' => 'Doctrine\DBAL\Types\DecimalType', 'decimal' => 'Doctrine\DBAL\Types\DecimalType',
'double' => 'Doctrine\DBAL\Types\DoubleType' 'double' => 'Doctrine\DBAL\Types\DoubleType'
); );
/* Prevent instantiation and force use of the factory method. */ /* Prevent instantiation and force use of the factory method. */
private function __construct() {} private function __construct() {}
/** /**
* Converts a value from its PHP representation to its database representation * Converts a value from its PHP representation to its database representation
* of this type. * of this type.
...@@ -74,7 +73,7 @@ abstract class Type ...@@ -74,7 +73,7 @@ abstract class Type
{ {
return $value; return $value;
} }
/** /**
* Gets the default length of this type. * Gets the default length of this type.
* *
...@@ -84,7 +83,7 @@ abstract class Type ...@@ -84,7 +83,7 @@ abstract class Type
{ {
return null; return null;
} }
/** /**
* Gets the SQL declaration snippet for a field of this type. * Gets the SQL declaration snippet for a field of this type.
* *
...@@ -95,7 +94,7 @@ abstract class Type ...@@ -95,7 +94,7 @@ abstract class Type
/** /**
* Gets the name of this type. * Gets the name of this type.
* *
* @return string * @return string
* @todo Needed? * @todo Needed?
*/ */
...@@ -103,14 +102,14 @@ abstract class Type ...@@ -103,14 +102,14 @@ abstract class Type
/** /**
* Gets the type code of this type. * Gets the type code of this type.
* *
* @return integer * @return integer
*/ */
public function getTypeCode() public function getTypeCode()
{ {
return self::CODE_STR; return self::CODE_STR;
} }
/** /**
* Factory method to create type instances. * Factory method to create type instances.
* Type instances are implemented as flyweights. * Type instances are implemented as flyweights.
...@@ -126,13 +125,13 @@ abstract class Type ...@@ -126,13 +125,13 @@ abstract class Type
if ( ! isset(self::$_typesMap[$name])) { if ( ! isset(self::$_typesMap[$name])) {
throw DBALException::unknownColumnType($name); throw DBALException::unknownColumnType($name);
} }
self::$_typeObjects[$name] = new self::$_typesMap[$name](); self::$_typeObjects[$name] = new self::$_typesMap[$name]();
} }
return self::$_typeObjects[$name]; return self::$_typeObjects[$name];
} }
/** /**
* Adds a custom type to the type map. * Adds a custom type to the type map.
* *
...@@ -147,10 +146,10 @@ abstract class Type ...@@ -147,10 +146,10 @@ abstract class Type
if (isset(self::$_typesMap[$name])) { if (isset(self::$_typesMap[$name])) {
throw DBALException::typeExists($name); throw DBALException::typeExists($name);
} }
self::$_typesMap[$name] = $className; self::$_typesMap[$name] = $className;
} }
/** /**
* Checks if exists support for a type. * Checks if exists support for a type.
* *
...@@ -162,7 +161,7 @@ abstract class Type ...@@ -162,7 +161,7 @@ abstract class Type
{ {
return isset(self::$_typesMap[$name]); return isset(self::$_typesMap[$name]);
} }
/** /**
* Overrides an already defined type to use a different implementation. * Overrides an already defined type to use a different implementation.
* *
...@@ -176,7 +175,7 @@ abstract class Type ...@@ -176,7 +175,7 @@ abstract class Type
if ( ! isset(self::$_typesMap[$name])) { if ( ! isset(self::$_typesMap[$name])) {
throw DBALException::typeNotFound($name); throw DBALException::typeNotFound($name);
} }
self::$_typesMap[$name] = $className; self::$_typesMap[$name] = $className;
} }
......
...@@ -227,7 +227,7 @@ abstract class AbstractQuery ...@@ -227,7 +227,7 @@ abstract class AbstractQuery
public function setResultCacheDriver($resultCacheDriver = null) public function setResultCacheDriver($resultCacheDriver = null)
{ {
if ($resultCacheDriver !== null && ! ($resultCacheDriver instanceof \Doctrine\Common\Cache\Cache)) { if ($resultCacheDriver !== null && ! ($resultCacheDriver instanceof \Doctrine\Common\Cache\Cache)) {
throw DoctrineException::invalidResultCacheObject($resultCacheDriver); throw ORMException::invalidResultCacheDriver();
} }
$this->_resultCacheDriver = $resultCacheDriver; $this->_resultCacheDriver = $resultCacheDriver;
if ($resultCacheDriver) { if ($resultCacheDriver) {
......
<?php <?php
/* /*
* $Id$ * $Id$
* *
...@@ -31,14 +31,14 @@ namespace Doctrine\ORM; ...@@ -31,14 +31,14 @@ namespace Doctrine\ORM;
* pair and add the option to the _attributes array with a proper default value. * pair and add the option to the _attributes array with a proper default value.
*/ */
class Configuration extends \Doctrine\DBAL\Configuration class Configuration extends \Doctrine\DBAL\Configuration
{ {
/** /**
* Creates a new configuration that can be used for Doctrine. * Creates a new configuration that can be used for Doctrine.
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
$this->_attributes = array_merge($this->_attributes, array( $this->_attributes = array_merge($this->_attributes, array(
'resultCacheImpl' => null, 'resultCacheImpl' => null,
'queryCacheImpl' => null, 'queryCacheImpl' => null,
...@@ -73,7 +73,7 @@ class Configuration extends \Doctrine\DBAL\Configuration ...@@ -73,7 +73,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
{ {
return $this->_attributes['proxyDir']; return $this->_attributes['proxyDir'];
} }
/** /**
* Gets a boolean flag that indicates whether proxy classes should always be regenerated * Gets a boolean flag that indicates whether proxy classes should always be regenerated
* during each script execution. * during each script execution.
...@@ -84,7 +84,7 @@ class Configuration extends \Doctrine\DBAL\Configuration ...@@ -84,7 +84,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
{ {
return $this->_attributes['autoGenerateProxyClasses']; return $this->_attributes['autoGenerateProxyClasses'];
} }
/** /**
* Sets a boolean flag that indicates whether proxy classes should always be regenerated * Sets a boolean flag that indicates whether proxy classes should always be regenerated
* during each script execution. * during each script execution.
...@@ -95,12 +95,12 @@ class Configuration extends \Doctrine\DBAL\Configuration ...@@ -95,12 +95,12 @@ class Configuration extends \Doctrine\DBAL\Configuration
{ {
$this->_attributes['autoGenerateProxyClasses'] = $bool; $this->_attributes['autoGenerateProxyClasses'] = $bool;
} }
public function getProxyNamespace() public function getProxyNamespace()
{ {
return $this->_attributes['proxyNamespace']; return $this->_attributes['proxyNamespace'];
} }
public function setProxyNamespace($ns) public function setProxyNamespace($ns)
{ {
$this->_attributes['proxyNamespace'] = $ns; $this->_attributes['proxyNamespace'] = $ns;
...@@ -148,7 +148,7 @@ class Configuration extends \Doctrine\DBAL\Configuration ...@@ -148,7 +148,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
/** /**
* Set the entity alias map * Set the entity alias map
* *
* @param array $entityAliasMap * @param array $entityAliasMap
* @return void * @return void
*/ */
public function setEntityNamespaces(array $entityNamespaces) public function setEntityNamespaces(array $entityNamespaces)
...@@ -231,32 +231,32 @@ class Configuration extends \Doctrine\DBAL\Configuration ...@@ -231,32 +231,32 @@ class Configuration extends \Doctrine\DBAL\Configuration
{ {
$this->_attributes['metadataCacheImpl'] = $cacheImpl; $this->_attributes['metadataCacheImpl'] = $cacheImpl;
} }
/** /**
* Gets a boolean flag that indicates whether Doctrine should make use of the * Gets a boolean flag that indicates whether Doctrine should make use of the
* C extension. * C extension.
* *
* @return boolean TRUE if Doctrine is configured to use the C extension, FALSE otherwise. * @return boolean TRUE if Doctrine is configured to use the C extension, FALSE otherwise.
*/ */
public function getUseCExtension() public function getUseCExtension()
{ {
return $this->_attributes['useCExtension']; return $this->_attributes['useCExtension'];
} }
/** /**
* Sets a boolean flag that indicates whether Doctrine should make use of the * Sets a boolean flag that indicates whether Doctrine should make use of the
* C extension. * C extension.
* *
* @param boolean $boolean Whether to make use of the C extension or not. * @param boolean $boolean Whether to make use of the C extension or not.
*/ */
public function setUseCExtension($boolean) public function setUseCExtension($boolean)
{ {
$this->_attributes['useCExtension'] = $boolean; $this->_attributes['useCExtension'] = $boolean;
} }
/** /**
* Adds a named DQL query to the configuration. * Adds a named DQL query to the configuration.
* *
* @param string $name The name of the query. * @param string $name The name of the query.
* @param string $dql The DQL query string. * @param string $dql The DQL query string.
*/ */
...@@ -264,10 +264,10 @@ class Configuration extends \Doctrine\DBAL\Configuration ...@@ -264,10 +264,10 @@ class Configuration extends \Doctrine\DBAL\Configuration
{ {
$this->_attributes['namedQueries'][$name] = $dql; $this->_attributes['namedQueries'][$name] = $dql;
} }
/** /**
* Gets a previously registered named DQL query. * Gets a previously registered named DQL query.
* *
* @param string $name The name of the query. * @param string $name The name of the query.
* @return string The DQL query. * @return string The DQL query.
*/ */
...@@ -275,22 +275,22 @@ class Configuration extends \Doctrine\DBAL\Configuration ...@@ -275,22 +275,22 @@ class Configuration extends \Doctrine\DBAL\Configuration
{ {
return $this->_attributes['namedQueries'][$name]; return $this->_attributes['namedQueries'][$name];
} }
/** /**
* Adds a named native query to the configuration. * Adds a named native query to the configuration.
* *
* @param string $name The name of the query. * @param string $name The name of the query.
* @param string $sql The native SQL query string. * @param string $sql The native SQL query string.
* @param ResultSetMapping $rsm The ResultSetMapping used for the results of the SQL query. * @param ResultSetMapping $rsm The ResultSetMapping used for the results of the SQL query.
*/ */
public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm) public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm)
{ {
$this->_attributes['namedNativeQueries'][$name] = array($sql, $rsm); $this->_attributes['namedNativeQueries'][$name] = array($sql, $rsm);
} }
/** /**
* Gets the components of a previously registered named native query. * Gets the components of a previously registered named native query.
* *
* @param string $name The name of the query. * @param string $name The name of the query.
* @return array A tuple with the first element being the SQL string and the second * @return array A tuple with the first element being the SQL string and the second
* element being the ResultSetMapping. * element being the ResultSetMapping.
...@@ -299,13 +299,13 @@ class Configuration extends \Doctrine\DBAL\Configuration ...@@ -299,13 +299,13 @@ class Configuration extends \Doctrine\DBAL\Configuration
{ {
return $this->_attributes['namedNativeQueries'][$name]; return $this->_attributes['namedNativeQueries'][$name];
} }
/** /**
* Ensures that this Configuration instance contains settings that are * Ensures that this Configuration instance contains settings that are
* suitable for a production environment. * suitable for a production environment.
* *
* @throws DoctrineException If a configuration setting has a value that is not * @throws ORMException If a configuration setting has a value that is not
* suitable for a production environment. * suitable for a production environment.
*/ */
public function ensureProductionSettings() public function ensureProductionSettings()
{ {
......
...@@ -61,7 +61,7 @@ class SequenceGenerator extends AbstractIdGenerator implements \Serializable ...@@ -61,7 +61,7 @@ class SequenceGenerator extends AbstractIdGenerator implements \Serializable
if ($this->_maxValue === null || $this->_nextValue == $this->_maxValue) { if ($this->_maxValue === null || $this->_nextValue == $this->_maxValue) {
// Allocate new values // Allocate new values
$conn = $em->getConnection(); $conn = $em->getConnection();
$sql = $conn->getDatabasePlatform()->getSequenceNextValSql($this->_sequenceName); $sql = $conn->getDatabasePlatform()->getSequenceNextValSQL($this->_sequenceName);
$this->_nextValue = $conn->fetchColumn($sql); $this->_nextValue = $conn->fetchColumn($sql);
$this->_maxValue = $this->_nextValue + $this->_allocationSize; $this->_maxValue = $this->_nextValue + $this->_allocationSize;
} }
......
...@@ -5,7 +5,7 @@ namespace Doctrine\ORM\Id; ...@@ -5,7 +5,7 @@ namespace Doctrine\ORM\Id;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
/** /**
* Id generator that uses a single-row database table and a hi/lo algorithm. * Id generator that uses a single-row database table and a hi/lo algorithm.
* *
* @since 2.0 * @since 2.0
* @todo Implementation * @todo Implementation
...@@ -14,6 +14,6 @@ class TableGenerator extends AbstractIdGenerator ...@@ -14,6 +14,6 @@ class TableGenerator extends AbstractIdGenerator
{ {
public function generate(EntityManager $em, $entity) public function generate(EntityManager $em, $entity)
{ {
throw \Doctrine\Common\DoctrineException::notImplemented(__CLASS__ . '::' . __FUNCTION__); throw new \BadMethodCallException(__CLASS__."::".__FUNCTION__." not implemented.");
} }
} }
\ No newline at end of file
...@@ -79,19 +79,18 @@ class CommitOrderCalculator ...@@ -79,19 +79,18 @@ class CommitOrderCalculator
$this->_visitNode($node); $this->_visitNode($node);
} }
} }
$sorted = array_reverse($this->_sorted); $sorted = array_reverse($this->_sorted);
$this->_sorted = $this->_sorted = $this->_nodeStates = array();
$this->_nodeStates = array();
return $sorted; return $sorted;
} }
private function _visitNode($node) private function _visitNode($node)
{ {
$this->_nodeStates[$node->name] = self::IN_PROGRESS; $this->_nodeStates[$node->name] = self::IN_PROGRESS;
if (isset($this->_relatedClasses[$node->name])) { if (isset($this->_relatedClasses[$node->name])) {
foreach ($this->_relatedClasses[$node->name] as $relatedNode) { foreach ($this->_relatedClasses[$node->name] as $relatedNode) {
if ($this->_nodeStates[$relatedNode->name] == self::NOT_VISITED) { if ($this->_nodeStates[$relatedNode->name] == self::NOT_VISITED) {
...@@ -99,7 +98,7 @@ class CommitOrderCalculator ...@@ -99,7 +98,7 @@ class CommitOrderCalculator
} }
} }
} }
$this->_nodeStates[$node->name] = self::VISITED; $this->_nodeStates[$node->name] = self::VISITED;
$this->_sorted[] = $node; $this->_sorted[] = $node;
} }
......
...@@ -176,15 +176,6 @@ class ClassMetadata extends ClassMetadataInfo ...@@ -176,15 +176,6 @@ class ClassMetadata extends ClassMetadataInfo
return array($this->identifier[0] => $this->reflFields[$this->identifier[0]]->getValue($entity)); return array($this->identifier[0] => $this->reflFields[$this->identifier[0]]->getValue($entity));
} }
} }
public function getColumnValues($entity, array $columns)
{
$values = array();
foreach ($columns as $column) {
$values[] = $this->reflFields[$this->fieldNames[$column]]->getValue($entity);
}
return $values;
}
/** /**
* Populates the entity identifier of an entity. * Populates the entity identifier of an entity.
...@@ -287,21 +278,7 @@ class ClassMetadata extends ClassMetadataInfo ...@@ -287,21 +278,7 @@ class ClassMetadata extends ClassMetadataInfo
$platform->quoteIdentifier($this->primaryTable['name']) : $platform->quoteIdentifier($this->primaryTable['name']) :
$this->primaryTable['name']; $this->primaryTable['name'];
} }
/**
* Gets the (possibly quoted) name of the discriminator column for safe use
* in an SQL statement.
*
* @param AbstractPlatform $platform
* @return string
*/
public function getQuotedDiscriminatorColumnName($platform)
{
return isset($this->discriminatorColumn['quoted']) ?
$platform->quoteIdentifier($this->discriminatorColumn['name']) :
$this->discriminatorColumn['name'];
}
/** /**
* Creates a string representation of this instance. * Creates a string representation of this instance.
* *
......
...@@ -130,12 +130,13 @@ class ClassMetadataFactory ...@@ -130,12 +130,13 @@ class ClassMetadataFactory
if ( ! isset($this->_loadedMetadata[$className])) { if ( ! isset($this->_loadedMetadata[$className])) {
$realClassName = $className; $realClassName = $className;
// Check for namespace alias
if (strpos($className, ':') !== false) { if (strpos($className, ':') !== false) {
list($namespaceAlias, $simpleClassName) = explode(':', $className); list($namespaceAlias, $simpleClassName) = explode(':', $className);
$realClassName = $this->_em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName; $realClassName = $this->_em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
if (isset($this->_loadedMetadata[$realClassName])) { if (isset($this->_loadedMetadata[$realClassName])) {
// We do not have the alias reference, include it // We do not have the alias name in the map, include it
$this->_loadedMetadata[$className] = $this->_loadedMetadata[$realClassName]; $this->_loadedMetadata[$className] = $this->_loadedMetadata[$realClassName];
return $this->_loadedMetadata[$realClassName]; return $this->_loadedMetadata[$realClassName];
...@@ -158,9 +159,8 @@ class ClassMetadataFactory ...@@ -158,9 +159,8 @@ class ClassMetadataFactory
$this->_loadMetadata($realClassName); $this->_loadMetadata($realClassName);
} }
// Include the alias of this situation:
// CMS:CmsUser => Doctrine\Tests\ORM\Models\CMS\CmsUser
if ($className != $realClassName) { if ($className != $realClassName) {
// We do not have the alias name in the map, include it
$this->_loadedMetadata[$className] = $this->_loadedMetadata[$realClassName]; $this->_loadedMetadata[$className] = $this->_loadedMetadata[$realClassName];
} }
} }
......
...@@ -42,13 +42,13 @@ require __DIR__ . '/DoctrineAnnotations.php'; ...@@ -42,13 +42,13 @@ require __DIR__ . '/DoctrineAnnotations.php';
*/ */
class AnnotationDriver implements Driver class AnnotationDriver implements Driver
{ {
/** /**
* The AnnotationReader. * The AnnotationReader.
* *
* @var AnnotationReader * @var AnnotationReader
*/ */
private $_reader; private $_reader;
/** /**
* The paths where to look for mapping files. * The paths where to look for mapping files.
* *
...@@ -66,7 +66,7 @@ class AnnotationDriver implements Driver ...@@ -66,7 +66,7 @@ class AnnotationDriver implements Driver
/** /**
* @param array * @param array
*/ */
protected $_classNames = null; protected $_classNames;
/** /**
* Initializes a new AnnotationDriver that uses the given AnnotationReader for reading * Initializes a new AnnotationDriver that uses the given AnnotationReader for reading
...@@ -93,7 +93,7 @@ class AnnotationDriver implements Driver ...@@ -93,7 +93,7 @@ class AnnotationDriver implements Driver
{ {
$this->_paths = array_unique(array_merge($this->_paths, $paths)); $this->_paths = array_unique(array_merge($this->_paths, $paths));
} }
/** /**
* Retrieve the defined metadata lookup paths. * Retrieve the defined metadata lookup paths.
* *
...@@ -131,7 +131,7 @@ class AnnotationDriver implements Driver ...@@ -131,7 +131,7 @@ class AnnotationDriver implements Driver
public function loadMetadataForClass($className, ClassMetadataInfo $metadata) public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
{ {
$class = $metadata->getReflectionClass(); $class = $metadata->getReflectionClass();
$classAnnotations = $this->_reader->getClassAnnotations($class); $classAnnotations = $this->_reader->getClassAnnotations($class);
// Evaluate Entity annotation // Evaluate Entity annotation
...@@ -151,7 +151,7 @@ class AnnotationDriver implements Driver ...@@ -151,7 +151,7 @@ class AnnotationDriver implements Driver
'name' => $tableAnnot->name, 'name' => $tableAnnot->name,
'schema' => $tableAnnot->schema 'schema' => $tableAnnot->schema
); );
if ($tableAnnot->indexes !== null) { if ($tableAnnot->indexes !== null) {
foreach ($tableAnnot->indexes as $indexAnnot) { foreach ($tableAnnot->indexes as $indexAnnot) {
$primaryTable['indexes'][$indexAnnot->name] = array( $primaryTable['indexes'][$indexAnnot->name] = array(
...@@ -159,7 +159,7 @@ class AnnotationDriver implements Driver ...@@ -159,7 +159,7 @@ class AnnotationDriver implements Driver
); );
} }
} }
if ($tableAnnot->uniqueConstraints !== null) { if ($tableAnnot->uniqueConstraints !== null) {
foreach ($tableAnnot->uniqueConstraints as $uniqueConstraint) { foreach ($tableAnnot->uniqueConstraints as $uniqueConstraint) {
$primaryTable['uniqueConstraints'][$uniqueConstraint->name] = array( $primaryTable['uniqueConstraints'][$uniqueConstraint->name] = array(
...@@ -167,7 +167,7 @@ class AnnotationDriver implements Driver ...@@ -167,7 +167,7 @@ class AnnotationDriver implements Driver
); );
} }
} }
$metadata->setPrimaryTable($primaryTable); $metadata->setPrimaryTable($primaryTable);
} }
...@@ -214,7 +214,7 @@ class AnnotationDriver implements Driver ...@@ -214,7 +214,7 @@ class AnnotationDriver implements Driver
// Check for JoinColummn/JoinColumns annotations // Check for JoinColummn/JoinColumns annotations
$joinColumns = array(); $joinColumns = array();
if ($joinColumnAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\JoinColumn')) { if ($joinColumnAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\JoinColumn')) {
$joinColumns[] = array( $joinColumns[] = array(
'name' => $joinColumnAnnot->name, 'name' => $joinColumnAnnot->name,
...@@ -245,7 +245,7 @@ class AnnotationDriver implements Driver ...@@ -245,7 +245,7 @@ class AnnotationDriver implements Driver
if ($columnAnnot->type == null) { if ($columnAnnot->type == null) {
throw MappingException::propertyTypeIsRequired($className, $property->getName()); throw MappingException::propertyTypeIsRequired($className, $property->getName());
} }
$mapping['type'] = $columnAnnot->type; $mapping['type'] = $columnAnnot->type;
$mapping['length'] = $columnAnnot->length; $mapping['length'] = $columnAnnot->length;
$mapping['precision'] = $columnAnnot->precision; $mapping['precision'] = $columnAnnot->precision;
...@@ -255,27 +255,27 @@ class AnnotationDriver implements Driver ...@@ -255,27 +255,27 @@ class AnnotationDriver implements Driver
if ($columnAnnot->options) { if ($columnAnnot->options) {
$mapping['options'] = $columnAnnot->options; $mapping['options'] = $columnAnnot->options;
} }
if (isset($columnAnnot->name)) { if (isset($columnAnnot->name)) {
$mapping['columnName'] = $columnAnnot->name; $mapping['columnName'] = $columnAnnot->name;
} }
if (isset($columnAnnot->columnDefinition)) { if (isset($columnAnnot->columnDefinition)) {
$mapping['columnDefinition'] = $columnAnnot->columnDefinition; $mapping['columnDefinition'] = $columnAnnot->columnDefinition;
} }
if ($idAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Id')) { if ($idAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Id')) {
$mapping['id'] = true; $mapping['id'] = true;
} }
if ($generatedValueAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\GeneratedValue')) { if ($generatedValueAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\GeneratedValue')) {
$metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' . $generatedValueAnnot->strategy)); $metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' . $generatedValueAnnot->strategy));
} }
if ($versionAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Version')) { if ($versionAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Version')) {
$metadata->setVersionMapping($mapping); $metadata->setVersionMapping($mapping);
} }
$metadata->mapField($mapping); $metadata->mapField($mapping);
// Check for SequenceGenerator/TableGenerator definition // Check for SequenceGenerator/TableGenerator definition
...@@ -316,13 +316,13 @@ class AnnotationDriver implements Driver ...@@ -316,13 +316,13 @@ class AnnotationDriver implements Driver
$metadata->mapManyToOne($mapping); $metadata->mapManyToOne($mapping);
} else if ($manyToManyAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\ManyToMany')) { } else if ($manyToManyAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\ManyToMany')) {
$joinTable = array(); $joinTable = array();
if ($joinTableAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\JoinTable')) { if ($joinTableAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\JoinTable')) {
$joinTable = array( $joinTable = array(
'name' => $joinTableAnnot->name, 'name' => $joinTableAnnot->name,
'schema' => $joinTableAnnot->schema 'schema' => $joinTableAnnot->schema
); );
foreach ($joinTableAnnot->joinColumns as $joinColumn) { foreach ($joinTableAnnot->joinColumns as $joinColumn) {
$joinTable['joinColumns'][] = array( $joinTable['joinColumns'][] = array(
'name' => $joinColumn->name, 'name' => $joinColumn->name,
...@@ -347,7 +347,7 @@ class AnnotationDriver implements Driver ...@@ -347,7 +347,7 @@ class AnnotationDriver implements Driver
); );
} }
} }
$mapping['joinTable'] = $joinTable; $mapping['joinTable'] = $joinTable;
$mapping['targetEntity'] = $manyToManyAnnot->targetEntity; $mapping['targetEntity'] = $manyToManyAnnot->targetEntity;
$mapping['mappedBy'] = $manyToManyAnnot->mappedBy; $mapping['mappedBy'] = $manyToManyAnnot->mappedBy;
...@@ -361,37 +361,37 @@ class AnnotationDriver implements Driver ...@@ -361,37 +361,37 @@ class AnnotationDriver implements Driver
$metadata->mapManyToMany($mapping); $metadata->mapManyToMany($mapping);
} }
} }
// Evaluate HasLifecycleCallbacks annotation // Evaluate HasLifecycleCallbacks annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\HasLifecycleCallbacks'])) { if (isset($classAnnotations['Doctrine\ORM\Mapping\HasLifecycleCallbacks'])) {
foreach ($class->getMethods() as $method) { foreach ($class->getMethods() as $method) {
if ($method->isPublic()) { if ($method->isPublic()) {
$annotations = $this->_reader->getMethodAnnotations($method); $annotations = $this->_reader->getMethodAnnotations($method);
if (isset($annotations['Doctrine\ORM\Mapping\PrePersist'])) { if (isset($annotations['Doctrine\ORM\Mapping\PrePersist'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::prePersist); $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::prePersist);
} }
if (isset($annotations['Doctrine\ORM\Mapping\PostPersist'])) { if (isset($annotations['Doctrine\ORM\Mapping\PostPersist'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postPersist); $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postPersist);
} }
if (isset($annotations['Doctrine\ORM\Mapping\PreUpdate'])) { if (isset($annotations['Doctrine\ORM\Mapping\PreUpdate'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preUpdate); $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preUpdate);
} }
if (isset($annotations['Doctrine\ORM\Mapping\PostUpdate'])) { if (isset($annotations['Doctrine\ORM\Mapping\PostUpdate'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postUpdate); $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postUpdate);
} }
if (isset($annotations['Doctrine\ORM\Mapping\PreRemove'])) { if (isset($annotations['Doctrine\ORM\Mapping\PreRemove'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preRemove); $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preRemove);
} }
if (isset($annotations['Doctrine\ORM\Mapping\PostRemove'])) { if (isset($annotations['Doctrine\ORM\Mapping\PostRemove'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postRemove); $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postRemove);
} }
if (isset($annotations['Doctrine\ORM\Mapping\PostLoad'])) { if (isset($annotations['Doctrine\ORM\Mapping\PostLoad'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postLoad); $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postLoad);
} }
...@@ -412,11 +412,11 @@ class AnnotationDriver implements Driver ...@@ -412,11 +412,11 @@ class AnnotationDriver implements Driver
public function isTransient($className) public function isTransient($className)
{ {
$classAnnotations = $this->_reader->getClassAnnotations(new \ReflectionClass($className)); $classAnnotations = $this->_reader->getClassAnnotations(new \ReflectionClass($className));
return ! isset($classAnnotations['Doctrine\ORM\Mapping\Entity']) && return ! isset($classAnnotations['Doctrine\ORM\Mapping\Entity']) &&
! isset($classAnnotations['Doctrine\ORM\Mapping\MappedSuperclass']); ! isset($classAnnotations['Doctrine\ORM\Mapping\MappedSuperclass']);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
...@@ -427,32 +427,32 @@ class AnnotationDriver implements Driver ...@@ -427,32 +427,32 @@ class AnnotationDriver implements Driver
} }
$classes = array(); $classes = array();
if ($this->_paths) { if ($this->_paths) {
$declared = get_declared_classes(); $declared = get_declared_classes();
foreach ((array) $this->_paths as $path) { foreach ((array) $this->_paths as $path) {
if ( ! is_dir($path)) { if ( ! is_dir($path)) {
throw MappingException::annotationDriverRequiresConfiguredDirectoryPath(); throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath();
} }
$iterator = new \RecursiveIteratorIterator( $iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($path), new \RecursiveDirectoryIterator($path),
\RecursiveIteratorIterator::LEAVES_ONLY \RecursiveIteratorIterator::LEAVES_ONLY
); );
foreach ($iterator as $file) { foreach ($iterator as $file) {
if (($fileName = $file->getBasename($this->_fileExtension)) == $file->getBasename()) { if (($fileName = $file->getBasename($this->_fileExtension)) == $file->getBasename()) {
continue; continue;
} }
require_once $file->getPathName(); require_once $file->getPathName();
} }
} }
$declared = array_diff(get_declared_classes(), $declared); $declared = array_diff(get_declared_classes(), $declared);
foreach ($declared as $className) { foreach ($declared as $className) {
if ( ! $this->isTransient($className)) { if ( ! $this->isTransient($className)) {
$classes[] = $className; $classes[] = $className;
} }
...@@ -460,8 +460,8 @@ class AnnotationDriver implements Driver ...@@ -460,8 +460,8 @@ class AnnotationDriver implements Driver
} }
$this->_classNames = $classes; $this->_classNames = $classes;
return $classes; return $classes;
} }
} }
\ No newline at end of file
...@@ -126,27 +126,19 @@ class ManyToManyMapping extends AssociationMapping ...@@ -126,27 +126,19 @@ class ManyToManyMapping extends AssociationMapping
); );
} }
foreach ($mapping['joinTable']['joinColumns'] as &$joinColumn) { foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {
if ($joinColumn['name'][0] == '`') {
$joinColumn['name'] = trim($joinColumn['name'], '`');
$joinColumn['quoted'] = true;
}
$this->relationToSourceKeyColumns[$joinColumn['name']] = $joinColumn['referencedColumnName']; $this->relationToSourceKeyColumns[$joinColumn['name']] = $joinColumn['referencedColumnName'];
$this->joinTableColumns[] = $joinColumn['name']; $this->joinTableColumns[] = $joinColumn['name'];
} }
foreach ($mapping['joinTable']['inverseJoinColumns'] as &$inverseJoinColumn) { foreach ($mapping['joinTable']['inverseJoinColumns'] as $inverseJoinColumn) {
if ($inverseJoinColumn['name'][0] == '`') {
$inverseJoinColumn['name'] = trim($inverseJoinColumn['name'], '`');
$inverseJoinColumn['quoted'] = true;
}
$this->relationToTargetKeyColumns[$inverseJoinColumn['name']] = $inverseJoinColumn['referencedColumnName']; $this->relationToTargetKeyColumns[$inverseJoinColumn['name']] = $inverseJoinColumn['referencedColumnName'];
$this->joinTableColumns[] = $inverseJoinColumn['name']; $this->joinTableColumns[] = $inverseJoinColumn['name'];
} }
} }
if (isset($mapping['orderBy'])) { if (isset($mapping['orderBy'])) {
if (!is_array($mapping['orderBy'])) { if ( ! is_array($mapping['orderBy'])) {
throw new \InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy'])); throw new \InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy']));
} }
$this->orderBy = $mapping['orderBy']; $this->orderBy = $mapping['orderBy'];
...@@ -212,26 +204,8 @@ class ManyToManyMapping extends AssociationMapping ...@@ -212,26 +204,8 @@ class ManyToManyMapping extends AssociationMapping
$persister->loadManyToManyCollection($this, $joinTableConditions, $targetCollection); $persister->loadManyToManyCollection($this, $joinTableConditions, $targetCollection);
} }
/**
* {@inheritdoc}
*/
public function isManyToMany() public function isManyToMany()
{ {
return true; return true;
} }
/**
* Gets the (possibly quoted) column name of a join column that is safe to use
* in an SQL statement.
*
* @param string $joinColumn
* @param AbstractPlatform $platform
* @return string
*/
public function getQuotedJoinColumnName($joinColumn, $platform)
{
return isset($this->joinTable['joinColumns'][$joinColumn]['quoted']) ?
$platform->quoteIdentifier($joinColumn) :
$joinColumn;
}
} }
...@@ -166,9 +166,9 @@ class MappingException extends \Doctrine\ORM\ORMException ...@@ -166,9 +166,9 @@ class MappingException extends \Doctrine\ORM\ORMException
); );
} }
public static function annotationDriverRequiresConfiguredDirectoryPath() public static function fileMappingDriversRequireConfiguredDirectoryPath()
{ {
return new self('The annotation driver needs to have a directory path'); return new self('File mapping drivers must have a directory path');
} }
/** /**
......
...@@ -54,7 +54,7 @@ class OneToManyMapping extends AssociationMapping ...@@ -54,7 +54,7 @@ class OneToManyMapping extends AssociationMapping
/** /**
* Order this collection by the given SQL snippet. * Order this collection by the given SQL snippet.
*/ */
public $orderBy = null; public $orderBy;
/** /**
* Initializes a new OneToManyMapping. * Initializes a new OneToManyMapping.
......
...@@ -119,11 +119,7 @@ class OneToOneMapping extends AssociationMapping ...@@ -119,11 +119,7 @@ class OneToOneMapping extends AssociationMapping
'referencedColumnName' => 'id' 'referencedColumnName' => 'id'
)); ));
} }
foreach ($mapping['joinColumns'] as &$joinColumn) { foreach ($mapping['joinColumns'] as $joinColumn) {
if ($joinColumn['name'][0] == '`') {
$joinColumn['name'] = trim($joinColumn['name'], '`');
$joinColumn['quoted'] = true;
}
$this->sourceToTargetKeyColumns[$joinColumn['name']] = $joinColumn['referencedColumnName']; $this->sourceToTargetKeyColumns[$joinColumn['name']] = $joinColumn['referencedColumnName'];
$this->joinColumnFieldNames[$joinColumn['name']] = isset($joinColumn['fieldName']) $this->joinColumnFieldNames[$joinColumn['name']] = isset($joinColumn['fieldName'])
? $joinColumn['fieldName'] : $joinColumn['name']; ? $joinColumn['fieldName'] : $joinColumn['name'];
...@@ -194,22 +190,7 @@ class OneToOneMapping extends AssociationMapping ...@@ -194,22 +190,7 @@ class OneToOneMapping extends AssociationMapping
{ {
return true; return true;
} }
/**
* Gets the (possibly quoted) column name of a join column that is safe to use
* in an SQL statement.
*
* @param string $joinColumn
* @param AbstractPlatform $platform
* @return string
*/
public function getQuotedJoinColumnName($joinColumn, $platform)
{
return isset($this->joinColumns[$joinColumn]['quoted']) ?
$platform->quoteIdentifier($joinColumn) :
$joinColumn;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
......
...@@ -70,6 +70,14 @@ class ORMException extends \Exception ...@@ -70,6 +70,14 @@ class ORMException extends \Exception
); );
} }
public static function invalidResultCacheDriver() {
return new self("Invalid result cache driver; it must implement \Doctrine\Common\Cache\Cache.");
}
public static function notSupported() {
return new self("This behaviour is (currently) not supported by Doctrine 2");
}
public static function queryCacheNotConfigured() public static function queryCacheNotConfigured()
{ {
return new self('Query Cache is not configured.'); return new self('Query Cache is not configured.');
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
namespace Doctrine\ORM\Persisters; namespace Doctrine\ORM\Persisters;
use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\ClassMetadata;
/** /**
* Persister for entities that participate in a hierarchy mapped with the * Persister for entities that participate in a hierarchy mapped with the
...@@ -41,46 +41,41 @@ class SingleTablePersister extends StandardEntityPersister ...@@ -41,46 +41,41 @@ class SingleTablePersister extends StandardEntityPersister
parent::_prepareData($entity, $result, $isInsert); parent::_prepareData($entity, $result, $isInsert);
// Populate the discriminator column // Populate the discriminator column
if ($isInsert) { if ($isInsert) {
$discColumn = $this->_class->getQuotedDiscriminatorColumnName($this->_platform); $discColumn = $this->_class->discriminatorColumn['name'];
$result[$this->_class->getQuotedTableName($this->_platform)][$discColumn] = $result[$this->_class->getQuotedTableName($this->_platform)][$discColumn] =
$this->_class->discriminatorValue; $this->_class->discriminatorValue;
} }
} }
/** @override */ /** @override */
protected function _getSelectColumnList() protected function _getSelectColumnListSQL()
{ {
$setResultColumnNames = empty($this->_resultColumnNames); $columnList = parent::_getSelectColumnListSQL();
$columnList = parent::_getSelectColumnList();
// Append discriminator column // Append discriminator column
$columnList .= ', ' . $this->_class->getQuotedDiscriminatorColumnName($this->_platform); $discrColumn = $this->_class->discriminatorColumn['name'];
$columnList .= ", $discrColumn";
if ($setResultColumnNames) { $rootClass = $this->_em->getClassMetadata($this->_class->rootEntityName);
$resultColumnName = $this->_platform->getSqlResultCasing($this->_class->discriminatorColumn['name']); $tableAlias = $this->_getSQLTableAlias($rootClass);
$this->_resultColumnNames[$resultColumnName] = $this->_class->discriminatorColumn['name']; $resultColumnName = $this->_platform->getSQLResultCasing($discrColumn);
} $this->_resultColumnNames[$resultColumnName] = $discrColumn;
///$tableAlias = $this->_class->getQuotedTableName($this->_platform);
foreach ($this->_class->subClasses as $subClassName) { foreach ($this->_class->subClasses as $subClassName) {
$subClass = $this->_em->getClassMetadata($subClassName); $subClass = $this->_em->getClassMetadata($subClassName);
// Append subclass columns // Append subclass columns
foreach ($subClass->fieldMappings as $fieldName => $mapping) { foreach ($subClass->fieldMappings as $fieldName => $mapping) {
if ( ! isset($mapping['inherited'])) { if ( ! isset($mapping['inherited'])) {
$columnList .= ', ' . $subClass->getQuotedColumnName($fieldName, $this->_platform); $columnList .= ', ' . $this->_getSelectColumnSQL($fieldName, $subClass);
if ($setResultColumnNames) {
$resultColumnName = $this->_platform->getSqlResultCasing($mapping['columnName']);
$this->_resultColumnNames[$resultColumnName] = $mapping['columnName'];
}
} }
} }
// Append subclass foreign keys // Append subclass foreign keys
foreach ($subClass->associationMappings as $assoc) { foreach ($subClass->associationMappings as $assoc) {
if ($assoc->isOwningSide && $assoc->isOneToOne() && ! isset($subClass->inheritedAssociationFields[$assoc->sourceFieldName])) { if ($assoc->isOwningSide && $assoc->isOneToOne() && ! isset($subClass->inheritedAssociationFields[$assoc->sourceFieldName])) {
foreach ($assoc->targetToSourceKeyColumns as $srcColumn) { foreach ($assoc->targetToSourceKeyColumns as $srcColumn) {
$columnList .= ', ' /*. $tableAlias . '.'*/ . $assoc->getQuotedJoinColumnName($srcColumn, $this->_platform); $columnAlias = $srcColumn . $this->_sqlAliasCounter++;
if ($setResultColumnNames) { $columnList .= ', ' . $tableAlias . ".$srcColumn AS $columnAlias";
$resultColumnName = $this->_platform->getSqlResultCasing($srcColumn); $resultColumnName = $this->_platform->getSQLResultCasing($columnAlias);
if ( ! isset($this->_resultColumnNames[$resultColumnName])) {
$this->_resultColumnNames[$resultColumnName] = $srcColumn; $this->_resultColumnNames[$resultColumnName] = $srcColumn;
} }
} }
...@@ -90,20 +85,32 @@ class SingleTablePersister extends StandardEntityPersister ...@@ -90,20 +85,32 @@ class SingleTablePersister extends StandardEntityPersister
return $columnList; return $columnList;
} }
/** @override */ /** @override */
protected function _getInsertColumnList() protected function _getInsertColumnList()
{ {
$columns = parent::_getInsertColumnList(); $columns = parent::_getInsertColumnList();
// Add discriminator column to the INSERT SQL // Add discriminator column to the INSERT SQL
$columns[] = $this->_class->getQuotedDiscriminatorColumnName($this->_platform); $columns[] = $this->_class->discriminatorColumn['name'];
return $columns; return $columns;
} }
/** @override */ /** @override */
protected function _processSqlResult(array $sqlResult) protected function _processSQLResult(array $sqlResult)
{ {
return $this->_processSqlResultInheritanceAware($sqlResult); return $this->_processSQLResultInheritanceAware($sqlResult);
}
/** @override */
protected function _getSQLTableAlias(ClassMetadata $class)
{
if (isset($this->_sqlTableAliases[$class->rootEntityName])) {
return $this->_sqlTableAliases[$class->rootEntityName];
}
$tableAlias = $this->_em->getClassMetadata($class->rootEntityName)->primaryTable['name'][0] . $this->_sqlAliasCounter++;
$this->_sqlTableAliases[$class->rootEntityName] = $tableAlias;
return $tableAlias;
} }
} }
\ No newline at end of file
...@@ -23,8 +23,7 @@ namespace Doctrine\ORM\Proxy; ...@@ -23,8 +23,7 @@ namespace Doctrine\ORM\Proxy;
use Doctrine\ORM\EntityManager, use Doctrine\ORM\EntityManager,
Doctrine\ORM\Mapping\ClassMetadata, Doctrine\ORM\Mapping\ClassMetadata,
Doctrine\ORM\Mapping\AssociationMapping, Doctrine\ORM\Mapping\AssociationMapping;
Doctrine\Common\DoctrineException;
/** /**
* This factory is used to create proxy objects for entities at runtime. * This factory is used to create proxy objects for entities at runtime.
...@@ -56,17 +55,17 @@ class ProxyFactory ...@@ -56,17 +55,17 @@ class ProxyFactory
public function __construct(EntityManager $em, $proxyDir, $proxyNs, $autoGenerate = false) public function __construct(EntityManager $em, $proxyDir, $proxyNs, $autoGenerate = false)
{ {
if ( ! $proxyDir) { if ( ! $proxyDir) {
throw DoctrineException::proxyDirectoryRequired(); throw ProxyException::proxyDirectoryRequired();
} }
if ( ! $proxyNs) { if ( ! $proxyNs) {
throw DoctrineException::proxyNamespaceRequired(); throw ProxyException::proxyNamespaceRequired();
} }
$this->_em = $em; $this->_em = $em;
$this->_proxyDir = $proxyDir; $this->_proxyDir = $proxyDir;
$this->_autoGenerate = $autoGenerate; $this->_autoGenerate = $autoGenerate;
$this->_proxyNamespace = $proxyNs; $this->_proxyNamespace = $proxyNs;
} }
/** /**
* Gets a reference proxy instance for the entity of the given type and identified by * Gets a reference proxy instance for the entity of the given type and identified by
* the given identifier. * the given identifier.
...@@ -79,25 +78,25 @@ class ProxyFactory ...@@ -79,25 +78,25 @@ class ProxyFactory
{ {
$proxyClassName = str_replace('\\', '', $className) . 'Proxy'; $proxyClassName = str_replace('\\', '', $className) . 'Proxy';
$fqn = $this->_proxyNamespace . '\\' . $proxyClassName; $fqn = $this->_proxyNamespace . '\\' . $proxyClassName;
if ($this->_autoGenerate && ! class_exists($fqn, false)) { if ($this->_autoGenerate && ! class_exists($fqn, false)) {
$fileName = $this->_proxyDir . DIRECTORY_SEPARATOR . $proxyClassName . '.php'; $fileName = $this->_proxyDir . DIRECTORY_SEPARATOR . $proxyClassName . '.php';
$this->_generateProxyClass($this->_em->getClassMetadata($className), $proxyClassName, $fileName, self::$_proxyClassTemplate); $this->_generateProxyClass($this->_em->getClassMetadata($className), $proxyClassName, $fileName, self::$_proxyClassTemplate);
require $fileName; require $fileName;
} }
if ( ! $this->_em->getMetadataFactory()->hasMetadataFor($fqn)) { if ( ! $this->_em->getMetadataFactory()->hasMetadataFor($fqn)) {
$this->_em->getMetadataFactory()->setMetadataFor($fqn, $this->_em->getClassMetadata($className)); $this->_em->getMetadataFactory()->setMetadataFor($fqn, $this->_em->getClassMetadata($className));
} }
$entityPersister = $this->_em->getUnitOfWork()->getEntityPersister($className); $entityPersister = $this->_em->getUnitOfWork()->getEntityPersister($className);
return new $fqn($entityPersister, $identifier); return new $fqn($entityPersister, $identifier);
} }
/** /**
* Generates proxy classes for all given classes. * Generates proxy classes for all given classes.
* *
* @param array $classes The classes (ClassMetadata instances) for which to generate proxies. * @param array $classes The classes (ClassMetadata instances) for which to generate proxies.
* @param string $toDir The target directory of the proxy classes. If not specified, the * @param string $toDir The target directory of the proxy classes. If not specified, the
* directory configured on the Configuration of the EntityManager used * directory configured on the Configuration of the EntityManager used
...@@ -113,10 +112,10 @@ class ProxyFactory ...@@ -113,10 +112,10 @@ class ProxyFactory
$this->_generateProxyClass($class, $proxyClassName, $proxyFileName, self::$_proxyClassTemplate); $this->_generateProxyClass($class, $proxyClassName, $proxyFileName, self::$_proxyClassTemplate);
} }
} }
/** /**
* Generates a (reference or association) proxy class. * Generates a (reference or association) proxy class.
* *
* @param $class * @param $class
* @param $originalClassName * @param $originalClassName
* @param $proxyClassName * @param $proxyClassName
...@@ -144,33 +143,33 @@ class ProxyFactory ...@@ -144,33 +143,33 @@ class ProxyFactory
$proxyClassName, $className, $proxyClassName, $className,
$methods, $sleepImpl $methods, $sleepImpl
); );
$file = str_replace($placeholders, $replacements, $file); $file = str_replace($placeholders, $replacements, $file);
file_put_contents($fileName, $file); file_put_contents($fileName, $file);
} }
/** /**
* Generates the methods of a proxy class. * Generates the methods of a proxy class.
* *
* @param ClassMetadata $class * @param ClassMetadata $class
* @return string The code of the generated methods. * @return string The code of the generated methods.
*/ */
private function _generateMethods(ClassMetadata $class) private function _generateMethods(ClassMetadata $class)
{ {
$methods = ''; $methods = '';
foreach ($class->reflClass->getMethods() as $method) { foreach ($class->reflClass->getMethods() as $method) {
/* @var $method ReflectionMethod */ /* @var $method ReflectionMethod */
if ($method->isConstructor() || strtolower($method->getName()) == "__sleep") { if ($method->isConstructor() || strtolower($method->getName()) == "__sleep") {
continue; continue;
} }
if ($method->isPublic() && ! $method->isFinal() && ! $method->isStatic()) { if ($method->isPublic() && ! $method->isFinal() && ! $method->isStatic()) {
$methods .= PHP_EOL . ' public function ' . $method->getName() . '('; $methods .= PHP_EOL . ' public function ' . $method->getName() . '(';
$firstParam = true; $firstParam = true;
$parameterString = $argumentString = ''; $parameterString = $argumentString = '';
foreach ($method->getParameters() as $param) { foreach ($method->getParameters() as $param) {
if ($firstParam) { if ($firstParam) {
$firstParam = false; $firstParam = false;
...@@ -178,68 +177,68 @@ class ProxyFactory ...@@ -178,68 +177,68 @@ class ProxyFactory
$parameterString .= ', '; $parameterString .= ', ';
$argumentString .= ', '; $argumentString .= ', ';
} }
// We need to pick the type hint class too // We need to pick the type hint class too
if (($paramClass = $param->getClass()) !== null) { if (($paramClass = $param->getClass()) !== null) {
$parameterString .= '\\' . $paramClass->getName() . ' '; $parameterString .= '\\' . $paramClass->getName() . ' ';
} else if ($param->isArray()) { } else if ($param->isArray()) {
$parameterString .= 'array '; $parameterString .= 'array ';
} }
if ($param->isPassedByReference()) { if ($param->isPassedByReference()) {
$parameterString .= '&'; $parameterString .= '&';
} }
$parameterString .= '$' . $param->getName(); $parameterString .= '$' . $param->getName();
$argumentString .= '$' . $param->getName(); $argumentString .= '$' . $param->getName();
if ($param->isDefaultValueAvailable()) { if ($param->isDefaultValueAvailable()) {
$parameterString .= ' = ' . var_export($param->getDefaultValue(), true); $parameterString .= ' = ' . var_export($param->getDefaultValue(), true);
} }
} }
$methods .= $parameterString . ') {' . PHP_EOL; $methods .= $parameterString . ') {' . PHP_EOL;
$methods .= ' $this->_load();' . PHP_EOL; $methods .= ' $this->_load();' . PHP_EOL;
$methods .= ' return parent::' . $method->getName() . '(' . $argumentString . ');'; $methods .= ' return parent::' . $method->getName() . '(' . $argumentString . ');';
$methods .= PHP_EOL . ' }' . PHP_EOL; $methods .= PHP_EOL . ' }' . PHP_EOL;
} }
} }
return $methods; return $methods;
} }
/** /**
* Generates the code for the __sleep method for a proxy class. * Generates the code for the __sleep method for a proxy class.
* *
* @param $class * @param $class
* @return string * @return string
*/ */
private function _generateSleep(ClassMetadata $class) private function _generateSleep(ClassMetadata $class)
{ {
$sleepImpl = ''; $sleepImpl = '';
if ($class->reflClass->hasMethod('__sleep')) { if ($class->reflClass->hasMethod('__sleep')) {
$sleepImpl .= 'return parent::__sleep();'; $sleepImpl .= 'return parent::__sleep();';
} else { } else {
$sleepImpl .= 'return array('; $sleepImpl .= 'return array(';
$first = true; $first = true;
foreach ($class->getReflectionProperties() as $name => $prop) { foreach ($class->getReflectionProperties() as $name => $prop) {
if ($first) { if ($first) {
$first = false; $first = false;
} else { } else {
$sleepImpl .= ', '; $sleepImpl .= ', ';
} }
$sleepImpl .= "'" . $name . "'"; $sleepImpl .= "'" . $name . "'";
} }
$sleepImpl .= ');'; $sleepImpl .= ');';
} }
return $sleepImpl; return $sleepImpl;
} }
/** Reference Proxy class code template */ /** Reference Proxy class code template */
private static $_proxyClassTemplate = private static $_proxyClassTemplate =
'<?php '<?php
......
...@@ -41,7 +41,7 @@ class CurrentDateFunction extends FunctionNode ...@@ -41,7 +41,7 @@ class CurrentDateFunction extends FunctionNode
*/ */
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{ {
return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentDateSql(); return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentDateSQL();
} }
/** /**
......
...@@ -41,7 +41,7 @@ class CurrentTimeFunction extends FunctionNode ...@@ -41,7 +41,7 @@ class CurrentTimeFunction extends FunctionNode
*/ */
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{ {
return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimeSql(); return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimeSQL();
} }
/** /**
......
...@@ -20,7 +20,7 @@ class CurrentTimestampFunction extends FunctionNode ...@@ -20,7 +20,7 @@ class CurrentTimestampFunction extends FunctionNode
*/ */
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{ {
return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimestampSql(); return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimestampSQL();
} }
/** /**
......
...@@ -95,8 +95,8 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor ...@@ -95,8 +95,8 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
'type' => \Doctrine\DBAL\Types\Type::getType($rootClass->getTypeOfColumn($idColumnName)) 'type' => \Doctrine\DBAL\Types\Type::getType($rootClass->getTypeOfColumn($idColumnName))
); );
} }
$this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSql() . ' ' . $tempTable . ' (' $this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
. $conn->getDatabasePlatform()->getColumnDeclarationListSql($columnDefinitions) . $conn->getDatabasePlatform()->getColumnDeclarationListSQL($columnDefinitions)
. ', PRIMARY KEY(' . $idColumnList . '))'; . ', PRIMARY KEY(' . $idColumnList . '))';
$this->_dropTempTableSql = 'DROP TABLE ' . $tempTable; $this->_dropTempTableSql = 'DROP TABLE ' . $tempTable;
} }
......
...@@ -127,8 +127,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor ...@@ -127,8 +127,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
'type' => \Doctrine\DBAL\Types\Type::getType($rootClass->getTypeOfColumn($idColumnName)) 'type' => \Doctrine\DBAL\Types\Type::getType($rootClass->getTypeOfColumn($idColumnName))
); );
} }
$this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSql() . ' ' . $tempTable . ' (' $this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
. $platform->getColumnDeclarationListSql($columnDefinitions) . $platform->getColumnDeclarationListSQL($columnDefinitions)
. ', PRIMARY KEY(' . $idColumnList . '))'; . ', PRIMARY KEY(' . $idColumnList . '))';
$this->_dropTempTableSql = 'DROP TABLE ' . $tempTable; $this->_dropTempTableSql = 'DROP TABLE ' . $tempTable;
} }
......
This diff is collapsed.
...@@ -35,18 +35,18 @@ use Doctrine\ORM\Query\AST\PathExpression; ...@@ -35,18 +35,18 @@ use Doctrine\ORM\Query\AST\PathExpression;
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de> * @author Benjamin Eberlei <kontakt@beberlei.de>
*/ */
class QueryException extends \Doctrine\Common\DoctrineException class QueryException extends \Doctrine\ORM\ORMException
{ {
public static function syntaxError($message) public static function syntaxError($message)
{ {
return new self('[Syntax Error] ' . $message); return new self('[Syntax Error] ' . $message);
} }
public static function semanticalError($message) public static function semanticalError($message)
{ {
return new self('[Semantical Error] ' . $message); return new self('[Semantical Error] ' . $message);
} }
public static function invalidParameterPosition($pos) public static function invalidParameterPosition($pos)
{ {
return new self('Invalid parameter position: ' . $pos); return new self('Invalid parameter position: ' . $pos);
...@@ -66,15 +66,19 @@ class QueryException extends \Doctrine\Common\DoctrineException ...@@ -66,15 +66,19 @@ class QueryException extends \Doctrine\Common\DoctrineException
{ {
return new self("Invalid parameter: token ".$key." is not defined in the query."); return new self("Invalid parameter: token ".$key." is not defined in the query.");
} }
public static function invalidPathExpression($pathExpr) public static function invalidPathExpression($pathExpr)
{ {
return new self( return new self(
"Invalid PathExpression '" . $pathExpr->identificationVariable . "Invalid PathExpression '" . $pathExpr->identificationVariable .
"." . implode('.', $pathExpr->parts) . "'." "." . implode('.', $pathExpr->parts) . "'."
); );
} }
public static function invalidLiteral($literal) {
return new self("Invalid literal '$literal'");
}
/** /**
* @param Doctrine\ORM\Mapping\AssociationMapping $assoc * @param Doctrine\ORM\Mapping\AssociationMapping $assoc
*/ */
...@@ -85,7 +89,7 @@ class QueryException extends \Doctrine\Common\DoctrineException ...@@ -85,7 +89,7 @@ class QueryException extends \Doctrine\Common\DoctrineException
"in class ".$assoc->sourceEntityName." assocation ".$assoc->sourceFieldName "in class ".$assoc->sourceEntityName." assocation ".$assoc->sourceFieldName
); );
} }
public static function partialObjectsAreDangerous() public static function partialObjectsAreDangerous()
{ {
return new self( return new self(
...@@ -103,7 +107,7 @@ class QueryException extends \Doctrine\Common\DoctrineException ...@@ -103,7 +107,7 @@ class QueryException extends \Doctrine\Common\DoctrineException
"Use WITH to append additional join conditions to the association." "Use WITH to append additional join conditions to the association."
); );
} }
public static function associationPathInverseSideNotSupported() public static function associationPathInverseSideNotSupported()
{ {
return new self( return new self(
...@@ -111,7 +115,12 @@ class QueryException extends \Doctrine\Common\DoctrineException ...@@ -111,7 +115,12 @@ class QueryException extends \Doctrine\Common\DoctrineException
" in DQL queries. Use an explicit join instead." " in DQL queries. Use an explicit join instead."
); );
} }
// TODO: Add the $assoc to the error message
public static function iterateWithFetchJoinNotAllowed($assoc) {
return new self("Iterate with fetch join not allowed");
}
public static function associationPathCompositeKeyNotSupported() public static function associationPathCompositeKeyNotSupported()
{ {
return new self( return new self(
......
...@@ -161,6 +161,7 @@ class ResultSetMapping ...@@ -161,6 +161,7 @@ class ResultSetMapping
* *
* @param string $alias * @param string $alias
* @return boolean * @return boolean
* @todo Rename: isIndexed($alias)
*/ */
public function hasIndexBy($alias) public function hasIndexBy($alias)
{ {
...@@ -380,11 +381,11 @@ class ResultSetMapping ...@@ -380,11 +381,11 @@ class ResultSetMapping
} }
/** /**
* Adds a meta column (foreign key or discriminator column) to the result set.
* *
* @param $alias * @param $alias
* @param $columnName * @param $columnName
* @param $fieldName * @param $fieldName
* @return unknown_type
*/ */
public function addMetaResult($alias, $columnName, $fieldName) public function addMetaResult($alias, $columnName, $fieldName)
{ {
......
This diff is collapsed.
...@@ -21,8 +21,7 @@ ...@@ -21,8 +21,7 @@
namespace Doctrine\ORM\Tools; namespace Doctrine\ORM\Tools;
use Doctrine\Common\DoctrineException, use Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\ORM\Tools\Export\Driver\AbstractExporter, Doctrine\ORM\Tools\Export\Driver\AbstractExporter,
Doctrine\Common\Util\Inflector; Doctrine\Common\Util\Inflector;
...@@ -56,7 +55,7 @@ class ConvertDoctrine1Schema ...@@ -56,7 +55,7 @@ class ConvertDoctrine1Schema
* Constructor passes the directory or array of directories * Constructor passes the directory or array of directories
* to convert the Doctrine 1 schema files from * to convert the Doctrine 1 schema files from
* *
* @param string $from * @param string $from
* @author Jonathan Wage * @author Jonathan Wage
*/ */
public function __construct($from) public function __construct($from)
...@@ -169,7 +168,7 @@ class ConvertDoctrine1Schema ...@@ -169,7 +168,7 @@ class ConvertDoctrine1Schema
$column['type'] = $this->_legacyTypeMap[$column['type']]; $column['type'] = $this->_legacyTypeMap[$column['type']];
} }
if ( ! \Doctrine\DBAL\Types\Type::hasType($column['type'])) { if ( ! \Doctrine\DBAL\Types\Type::hasType($column['type'])) {
throw DoctrineException::couldNotMapDoctrine1Type($column['type']); throw ToolsException::couldNotMapDoctrine1Type($column['type']);
} }
$fieldMapping = array(); $fieldMapping = array();
...@@ -215,7 +214,7 @@ class ConvertDoctrine1Schema ...@@ -215,7 +214,7 @@ class ConvertDoctrine1Schema
foreach ($model['indexes'] as $name => $index) { foreach ($model['indexes'] as $name => $index) {
$type = (isset($index['type']) && $index['type'] == 'unique') $type = (isset($index['type']) && $index['type'] == 'unique')
? 'uniqueConstraints' : 'indexes'; ? 'uniqueConstraints' : 'indexes';
$metadata->primaryTable[$type][$name] = array( $metadata->primaryTable[$type][$name] = array(
'columns' => $index['fields'] 'columns' => $index['fields']
); );
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment