Commit 7206b1dd authored by romanb's avatar romanb

Added getters to AST. Removed Production::__call. Added visitor support to...

Added getters to AST. Removed Production::__call. Added visitor support to AST. (guilherme: dont shoot me yet :-). visitor support doesnt hurt even if we do not use it for SQL generation). Lots of other things.
parent 7757de96
......@@ -28,7 +28,8 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @todo Can this be removed?
*/
class Doctrine_Cache extends Doctrine_EventListener implements Countable, IteratorAggregate
{
......
This diff is collapsed.
......@@ -97,10 +97,6 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
/**
* Constructor.
* Creates a new collection that will hold instances of the type that is
* specified through the mapper. That means if the mapper is a mapper for
* the entity "User", then the resulting collection will be a collection of
* user objects.
*
* @param Doctrine_Mapper|string $mapper The mapper used by the collection.
* @param string $keyColumn The field name that will be used as the key
......@@ -120,7 +116,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
}
if ($keyField === null) {
$keyField = $mapper->getClassMetadata()->getAttribute(Doctrine::ATTR_COLL_KEY);
//$keyField = $mapper->getClassMetadata()->getAttribute(Doctrine::ATTR_COLL_KEY);
}
if ($keyField !== null) {
......@@ -366,6 +362,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
*
* @param mixed $key the key of the element
* @return boolean
* @todo Rename to containsKey().
*/
public function contains($key)
{
......@@ -432,6 +429,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* Returns the primary keys of all records in the collection.
*
* @return array An array containing all primary keys.
* @todo Rename.
*/
public function getPrimaryKeys()
{
......@@ -626,7 +624,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
foreach ($this->data as $key => $record) {
foreach ($coll as $k => $related) {
if ($related[$foreign] == $record[$local]) {
$this->data[$key]->setRelated($name, $related);
$this->data[$key]->_setRelated($name, $related);
}
}
}
......@@ -644,7 +642,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
}
}
$this->data[$key]->setRelated($name, $sub);
$this->data[$key]->_setRelated($name, $sub);
}
} else if ($rel instanceof Doctrine_Relation_Association) {
// @TODO composite key support
......@@ -663,7 +661,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$sub->add($related->get($name));
}
}
$this->data[$key]->setRelated($name, $sub);
$this->data[$key]->_setRelated($name, $sub);
}
}
......@@ -799,6 +797,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* @param string $type
* @param string $deep
* @return void
* @todo Move elsewhere.
*/
public function exportTo($type, $deep = false)
{
......@@ -817,6 +816,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* @param string $type
* @param string $data
* @return void
* @todo Move elsewhere.
*/
public function importFrom($type, $data)
{
......@@ -868,11 +868,9 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* @param Doctrine_Connection $conn optional connection parameter
* @return Doctrine_Collection
*/
public function save(Doctrine_Connection $conn = null)
public function save()
{
if ($conn == null) {
$conn = $this->_mapper->getConnection();
}
$conn = $this->_mapper->getConnection();
try {
$conn->beginInternalTransaction();
......@@ -893,18 +891,13 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
}
/**
* delete
* single shot delete
* deletes all records from this collection
* and uses only one database query to perform this operation
* Deletes all records from the collection.
*
* @return Doctrine_Collection
* @return void
*/
public function delete(Doctrine_Connection $conn = null)
{
if ($conn == null) {
$conn = $this->_mapper->getConnection();
}
public function delete($clearColl = false)
{
$conn = $this->_mapper->getConnection();
try {
$conn->beginInternalTransaction();
......@@ -919,9 +912,10 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$conn->rollback();
throw $e;
}
$this->data = array();
return $this;
if ($clearColl) {
$this->clear();
}
}
......@@ -968,4 +962,9 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
{
return $this->relation;
}
public function clear()
{
$this->data = array();
}
}
......@@ -19,7 +19,7 @@
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::Core;
#namespace Doctrine::Common;
/**
* Doctrine_Configurable
......
<?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.phpdoctrine.org>.
*/
#namespace Doctrine::Common;
......@@ -6,8 +25,7 @@
/**
* The Configuration is the container for all configuration options of Doctrine.
* It combines all configuration options from DBAL & ORM to make it easy for the
* user.
* It combines all configuration options from DBAL & ORM.
*
* @since 2.0
*/
......@@ -33,12 +51,20 @@ class Doctrine_Configuration
'metadataCacheLifeSpan' => null
);
/**
* Creates a new configuration that can be used for Doctrine.
*/
public function __construct()
{
$this->_nullObject = Doctrine_Null::$INSTANCE;
$this->_initAttributes();
}
/**
* Initializes the attributes.
*
* @return void
*/
private function _initAttributes()
{
// Change null default values to references to the Null object to allow
......@@ -50,6 +76,12 @@ class Doctrine_Configuration
}
}
/**
* Gets the value of a configuration attribute.
*
* @param string $name
* @return mixed
*/
public function get($name)
{
if ( ! $this->hasAttribute($name)) {
......@@ -61,6 +93,12 @@ class Doctrine_Configuration
return $this->_attributes[$name];
}
/**
* Sets the value of a configuration attribute.
*
* @param string $name
* @param mixed $value
*/
public function set($name, $value)
{
if ( ! $this->hasAttribute($name)) {
......@@ -70,6 +108,12 @@ class Doctrine_Configuration
$this->_attributes[$name] = $value;
}
/**
* Checks whether the configuration contains/supports an attribute.
*
* @param string $name
* @return boolean
*/
public function has($name)
{
return isset($this->_attributes[$name]);
......
......@@ -73,7 +73,7 @@
* Doctrine::DBAL could ship with a simple standard resolver that uses a primitive
* round-robin approach to distribution. User can provide its own resolvers.
*/
abstract class Doctrine_Connection implements Doctrine_Configurable, Countable
abstract class Doctrine_Connection implements Countable
{
/**
* The PDO database handle.
......@@ -226,7 +226,7 @@ abstract class Doctrine_Connection implements Doctrine_Configurable, Countable
public function __construct(array $params)
{
if (isset($params['pdo'])) {
$this->dbh = $pdo;
$this->dbh = $params['pdo'];
$this->isConnected = true;
}
$this->_params = $params;
......@@ -278,6 +278,14 @@ abstract class Doctrine_Connection implements Doctrine_Configurable, Countable
return $this->_eventManager;
}
public function getProperty($name)
{
if ( ! isset($this->properties[$name])) {
throw Doctrine_Connection_Exception::unknownProperty($name);
}
return $this->properties[$name];
}
/**
* returns an array of available PDO drivers
*/
......@@ -626,10 +634,10 @@ abstract class Doctrine_Connection implements Doctrine_Configurable, Countable
if (strpos($str, '.')) {
$e = explode('.', $str);
return $this->formatter->quoteIdentifier($e[0], $checkOption) . '.'
. $this->formatter->quoteIdentifier($e[1], $checkOption);
return $this->getFormatter()->quoteIdentifier($e[0], $checkOption) . '.'
. $this->getFormatter()->quoteIdentifier($e[1], $checkOption);
}
return $this->formatter->quoteIdentifier($str, $checkOption);
return $this->getFormatter()->quoteIdentifier($str, $checkOption);
}
/**
......@@ -644,7 +652,7 @@ abstract class Doctrine_Connection implements Doctrine_Configurable, Countable
*/
public function convertBooleans($item)
{
return $this->formatter->convertBooleans($item);
return $this->getFormatter()->convertBooleans($item);
}
/**
......@@ -915,8 +923,8 @@ abstract class Doctrine_Connection implements Doctrine_Configurable, Countable
*/
public function rethrowException(Exception $e, $invoker)
{
$event = new Doctrine_Event($this, Doctrine_Event::CONN_ERROR);
$this->getListener()->preError($event);
//$event = new Doctrine_Event($this, Doctrine_Event::CONN_ERROR);
//$this->getListener()->preError($event);
$name = 'Doctrine_Connection_' . $this->driverName . '_Exception';
......@@ -930,7 +938,7 @@ abstract class Doctrine_Connection implements Doctrine_Configurable, Countable
throw $exc;
}
$this->getListener()->postError($event);
//$this->getListener()->postError($event);
}
/**
......@@ -951,15 +959,15 @@ abstract class Doctrine_Connection implements Doctrine_Configurable, Countable
*/
public function close()
{
$event = new Doctrine_Event($this, Doctrine_Event::CONN_CLOSE);
$this->getAttribute(Doctrine::ATTR_LISTENER)->preClose($event);
//$event = new Doctrine_Event($this, Doctrine_Event::CONN_CLOSE);
//this->getAttribute(Doctrine::ATTR_LISTENER)->preClose($event);
$this->clear();
unset($this->dbh);
$this->isConnected = false;
$this->getAttribute(Doctrine::ATTR_LISTENER)->postClose($event);
//$this->getAttribute(Doctrine::ATTR_LISTENER)->postClose($event);
}
/**
......@@ -1052,7 +1060,6 @@ abstract class Doctrine_Connection implements Doctrine_Configurable, Countable
}
/**
* rollback
* Cancel any database changes done during a transaction or since a specific
* savepoint that is in progress. This function may only be called when
* auto-committing is disabled, otherwise it will fail. Therefore, a new
......@@ -1061,9 +1068,9 @@ abstract class Doctrine_Connection implements Doctrine_Configurable, Countable
* this method can be listened with onPreTransactionRollback and onTransactionRollback
* eventlistener methods
*
* @param string $savepoint name of a savepoint to rollback to
* @throws Doctrine_Transaction_Exception if the rollback operation fails at database level
* @return boolean false if rollback couldn't be performed, true otherwise
* @param string $savepoint Name of a savepoint to rollback to.
* @throws Doctrine_Transaction_Exception If the rollback operation fails at database level.
* @return boolean FALSE if rollback couldn't be performed, TRUE otherwise.
*/
public function rollback($savepoint = null)
{
......@@ -1071,11 +1078,11 @@ abstract class Doctrine_Connection implements Doctrine_Configurable, Countable
}
/**
* createDatabase
*
* Method for creating the database for the connection instance
* Creates the database for the connection instance.
*
* @return mixed Will return an instance of the exception thrown if the create database fails, otherwise it returns a string detailing the success
* @return mixed Will return an instance of the exception thrown if the
* create database fails, otherwise it returns a string
* detailing the success.
*/
public function createDatabase()
{
......@@ -1116,7 +1123,8 @@ abstract class Doctrine_Connection implements Doctrine_Configurable, Countable
*
* Method for dropping the database for the connection instance
*
* @return mixed Will return an instance of the exception thrown if the drop database fails, otherwise it returns a string detailing the success
* @return mixed Will return an instance of the exception thrown if the drop
* database fails, otherwise it returns a string detailing the success.
*/
public function dropDatabase()
{
......@@ -1154,104 +1162,22 @@ abstract class Doctrine_Connection implements Doctrine_Configurable, Countable
*
* @param integer $attribute
* @return mixed
* @todo Implementation or remove if not needed. Configuration is the main
* container for all the attributes now.
*/
public function getAttribute($attribute)
{
if ($attribute == Doctrine::ATTR_QUOTE_IDENTIFIER) {
return false;
}
/* legacy */
if ($attribute >= 100) {
if ( ! isset($this->_attributes[$attribute])) {
return null;
}
return $this->_attributes[$attribute];
}
if ($this->isConnected) {
try {
return $this->dbh->getAttribute($attribute);
} catch (Exception $e) {
throw new Doctrine_Connection_Exception('Attribute ' . $attribute . ' not found.');
}
} else {
if ( ! isset($this->pendingAttributes[$attribute])) {
$this->connect();
$this->getAttribute($attribute);
}
return $this->pendingAttributes[$attribute];
}
}
/**
* setAttribute
* sets an attribute
*
* @todo why check for >= 100? has this any special meaning when creating
* attributes?
*
* @param integer $attribute
* @param mixed $value
* @return boolean
*/
public function setAttribute($attribute, $value)
{
if ($attribute >= 100) {
parent::setAttribute($attribute, $value);
} else {
if ($this->isConnected) {
$this->dbh->setAttribute($attribute, $value);
} else {
$this->pendingAttributes[$attribute] = $value;
}
}
return $this;
}
public function hasAttribute($name)
public function getFormatter()
{
return false;
}
/**
* __get
* lazy loads given module and returns it
*
* @see Doctrine_DataDict
* @see Doctrine_Expression
* @see Doctrine_Export
* @see Doctrine_Transaction
* @see Doctrine_Connection::$modules all availible modules
* @param string $name the name of the module to get
* @throws Doctrine_Connection_Exception if trying to get an unknown module
* @return Doctrine_Connection_Module connection module
*/
public function __get($name)
{
if (isset($this->properties[$name])) {
return $this->properties[$name];
}
if ( ! isset($this->modules[$name])) {
throw new Doctrine_Connection_Exception('Unknown module / property ' . $name);
}
if ($this->modules[$name] === false) {
switch ($name) {
case 'unitOfWork':
$this->modules[$name] = new Doctrine_Connection_UnitOfWork($this);
break;
case 'formatter':
$this->modules[$name] = new Doctrine_Formatter($this);
break;
default:
$class = 'Doctrine_' . ucwords($name) . '_' . $this->getDriverName();
$this->modules[$name] = new $class($this);
}
if ( ! $this->modules['formatter']) {
$this->modules['formatter'] = new Doctrine_Formatter($this);
}
return $this->modules[$name];
return $this->modules['formatter'];
}
}
......@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Connection');
/**
* Doctrine_Connection_Firebird
*
......@@ -101,7 +101,10 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection
* @return string modified query
*/
public function modifyLimitQuery($query, $limit, $offset)
{
{
if ( ! $offset) {
$offset = 0;
}
if ($limit > 0) {
$query = preg_replace('/^([\s(])*SELECT(?!\s*FIRST\s*\d+)/i',
"SELECT FIRST $limit SKIP $offset", $query);
......
......@@ -35,8 +35,10 @@
*/
class Doctrine_Connection_Mysql extends Doctrine_Connection_Common
{
/**
* @var string $driverName the name of this connection driver
/**
* Driver name.
*
* @var string
*/
protected $driverName = 'Mysql';
......@@ -46,11 +48,8 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common
* @param Doctrine_Manager $manager
* @param PDO|Doctrine_Adapter $adapter database handler
*/
public function __construct($adapter, $user = null, $pass = null)
public function __construct(array $params)
{
$this->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$this->setAttribute(Doctrine::ATTR_DEFAULT_TABLE_TYPE, 'INNODB');
$this->supported = array(
'sequences' => 'emulated',
'indexes' => true,
......@@ -91,7 +90,7 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common
$this->properties['varchar_max_length'] = 255;
parent::__construct($adapter, $user, $pass);
parent::__construct($params);
}
/**
......
......@@ -17,9 +17,9 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload("Doctrine_Connection_Common");
*/
#namespace Doctrine::DBAL::Connections;
/**
* Doctrine_Connection_Sqlite
......@@ -46,9 +46,10 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common
* @param Doctrine_Manager $manager
* @param PDO $pdo database handle
*/
public function __construct($adapter, $user = null, $pass = null)
public function __construct(array $params)
{
$this->supported = array('sequences' => 'emulated',
$this->supported = array(
'sequences' => 'emulated',
'indexes' => true,
'affected_rows' => true,
'summary_functions' => true,
......@@ -67,10 +68,10 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common
'identifier_quoting' => true,
'pattern_escaping' => false,
);
parent::__construct($adapter, $user, $pass);
parent::__construct($params);
if ($this->isConnected) {
$this->dbh->sqliteCreateFunction('mod', array('Doctrine_Expression_Sqlite', 'modImpl'), 2);
$this->dbh->sqliteCreateFunction('mod', array('Doctrine_Expression_Sqlite', 'modImpl'), 2);
$this->dbh->sqliteCreateFunction('md5', 'md5', 1);
$this->dbh->sqliteCreateFunction('now', 'time', 0);
}
......
......@@ -54,16 +54,7 @@
* @todo package:orm. Figure out a useful implementation.
*/
class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
{
/**
* A map of all currently managed entities.
*
* @var array
* @deprecated Only here to keep the saveAll() functionality working. We don't need
* this in the future.
*/
protected $_managedEntities = array();
{
/**
* The identity map that holds references to all managed entities that have
* an identity. The entities are grouped by their class name.
......@@ -131,7 +122,9 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
throw new Doctrine_Connection_Exception("Entity without identity "
. "can't be registered as new.");
}
$oid = $entity->getOid();
if (isset($this->_dirtyEntities[$oid])) {
throw new Doctrine_Connection_Exception("Dirty object can't be registered as new.");
} else if (isset($this->_removedEntities[$oid])) {
......@@ -139,6 +132,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
} else if (isset($this->_newEntities[$oid])) {
throw new Doctrine_Connection_Exception("Object already registered as new. Can't register twice.");
}
$this->registerIdentity($entity);
$this->_newEntities[$oid] = $entity;
}
......@@ -216,10 +211,10 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
* @param array $tables an array of Doctrine_Table objects or component names
* @return array an array of component names in flushing order
*/
public function buildFlushTree(array $mappers)
public function buildFlushTree(array $entityNames)
{
$tree = array();
foreach ($mappers as $k => $mapper) {
foreach ($entityNames as $k => $entity) {
if ( ! ($mapper instanceof Doctrine_Mapper)) {
$mapper = $this->conn->getMapper($mapper);
}
......@@ -487,6 +482,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
if ( ! $idHash) {
return false;
}
return isset($this->_identityMap
[$entity->getClassMetadata()->getRootClassName()]
[$idHash]);
......
<?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.phpdoctrine.org>.
*/
#namespace Doctrine::DBAL;
/**
* Factory for creating dbms-specific Connection instances.
*
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
*/
class Doctrine_ConnectionFactory
{
/**
* List of supported drivers and their mappings to the driver class.
*
* @var array
*/
private $_drivers = array(
'mysql' => 'Doctrine_Connection_Mysql',
'sqlite' => 'Doctrine_Connection_Sqlite',
......@@ -24,13 +54,26 @@ class Doctrine_ConnectionFactory
public function createConnection(array $params)
{
$this->_checkParams($params);
// check for existing pdo object
if (isset($params['pdo']) && ! $params['pdo'] instanceof PDO) {
throw Doctrine_ConnectionFactory_Exception::invalidPDOInstance();
} else if (isset($params['pdo'])) {
$params['driver'] = $params['pdo']->getAttribute(PDO::ATTR_DRIVER_NAME);
} else {
$this->_checkParams($params);
}
$className = $this->_drivers[$params['driver']];
return new $className($params);
}
/**
* Checks the list of parameters.
*
* @param array $params
*/
private function _checkParams(array $params)
{
{
// check existance of mandatory parameters
// driver
......@@ -52,10 +95,6 @@ class Doctrine_ConnectionFactory
if ( ! isset($this->_drivers[$params['driver']])) {
throw Doctrine_ConnectionFactory_Exception::unknownDriver($driverName);
}
// existing pdo object
if (isset($params['pdo']) && ! $params['pdo'] instanceof PDO) {
throw Doctrine_ConnectionFactory_Exception::invalidPDOInstance();
}
}
}
......
This diff is collapsed.
......@@ -42,7 +42,7 @@
* @author Roman Borschel <roman@code-factory.org>
* @todo package:orm
*/
class Doctrine_EntityManager implements Doctrine_Configurable
class Doctrine_EntityManager
{
/**
* The unique name of the EntityManager. The name is used to bind entity classes
......@@ -57,29 +57,9 @@ class Doctrine_EntityManager implements Doctrine_Configurable
*
* @var Configuration
*/
private $_configuration;
private $_config;
// -- configuration stuff to be removed. replaced by Configuration.
private $_nullObject;
/**
* The attributes.
*
* @var array
*/
private $_attributes = array(
'quoteIdentifier' => false,
'indexNameFormat' => '%s_idx',
'sequenceNameFormat' => '%s_seq',
'tableNameFormat' => '%s',
'resultCache' => null,
'resultCacheLifeSpan' => null,
'queryCache' => null,
'queryCacheLifeSpan' => null,
'metadataCache' => null,
'metadataCacheLifeSpan' => null
);
/**
* The database connection used by the EntityManager.
*
......@@ -150,6 +130,13 @@ class Doctrine_EntityManager implements Doctrine_Configurable
*/
//private $_dataTemplates = array();
/**
* Container that is used temporarily during hydration.
*
* @var array
*/
private $_tmpEntityData = array();
/**
* Creates a new EntityManager that operates on the given database connection.
*
......@@ -164,18 +151,6 @@ class Doctrine_EntityManager implements Doctrine_Configurable
$this, new Doctrine_ClassMetadata_CodeDriver());
$this->_unitOfWork = new Doctrine_Connection_UnitOfWork($conn);
$this->_nullObject = Doctrine_Null::$INSTANCE;
$this->_initAttributes();
}
private function _initAttributes()
{
// Change null default values to references to the Null object to allow
// fast isset() checks instead of array_key_exists().
foreach ($this->_attributes as $key => $value) {
if ($value === null) {
$this->_attributes[$key] = $this->_nullObject;
}
}
}
/**
......@@ -338,6 +313,17 @@ class Doctrine_EntityManager implements Doctrine_Configurable
$this->commit();
}
/**
* Enter description here...
*
* @param unknown_type $entityName
* @param unknown_type $identifier
*/
public function find($entityName, $identifier)
{
return $this->getRepository($entityName)->find($identifier);
}
/**
* Sets the flush mode.
*
......@@ -459,7 +445,7 @@ class Doctrine_EntityManager implements Doctrine_Configurable
}
/**
* Creates an entity. Used to reconstitution as well as new creation.
* Creates an entity. Used for reconstitution as well as initial creation.
*
* @param
* @param
......@@ -467,7 +453,8 @@ class Doctrine_EntityManager implements Doctrine_Configurable
*/
public function createEntity($className, array $data)
{
$className = $this->_getClassnameToReturn($data, $className);
$this->_tmpEntityData = $data;
$className = $this->_inferCorrectClassName($data, $className);
$classMetadata = $this->getClassMetadata($className);
if ( ! empty($data)) {
$identifierFieldNames = $classMetadata->getIdentifier();
......@@ -480,27 +467,45 @@ class Doctrine_EntityManager implements Doctrine_Configurable
}
$id[] = $data[$fieldName];
}
if ($isNew) {
return new $className(true, $data);
}
$idHash = $this->_unitOfWork->getIdentifierHash($id);
if ($entity = $this->_unitOfWork->tryGetByIdHash($idHash,
$classMetadata->getRootClassName())) {
return $entity;
$entity = new $className(true);
//$entity->_setData($data);
} else {
$entity = new $className(false, $data);
$this->_unitOfWork->registerIdentity($entity);
$idHash = $this->_unitOfWork->getIdentifierHash($id);
if ($entity = $this->_unitOfWork->tryGetByIdHash($idHash,
$classMetadata->getRootClassName())) {
return $entity;
} else {
$entity = new $className(false);
//$entity->_setData($data);
$this->_unitOfWork->registerIdentity($entity);
}
}
$data = array();
} else {
$entity = new $className(true, $data);
$entity = new $className(true);
//$entity->_setData($data);
}
/*if (count($data) < $classMetadata->getMappedColumnCount()) {
$entity->_state(Doctrine_Entity::STATE_PROXY);
} else {
$entity->_state(Doctrine_Entity::STATE_CLEAN);
}*/
$this->_tmpEntityData = array();
return $entity;
}
/**
* INTERNAL:
* For internal hydration purposes only.
*/
public function _getTmpEntityData()
{
return $this->_tmpEntityData;
}
/**
* Check the dataset for a discriminator column to determine the correct
* class to instantiate. If no discriminator column is found, the given
......@@ -508,9 +513,8 @@ class Doctrine_EntityManager implements Doctrine_Configurable
*
* @return string The name of the class to instantiate.
* @todo Can be optimized performance-wise.
* @todo Move to EntityManager::createEntity()
*/
private function _getClassnameToReturn(array $data, $className)
private function _inferCorrectClassName(array $data, $className)
{
$class = $this->getClassMetadata($className);
......@@ -565,35 +569,19 @@ class Doctrine_EntityManager implements Doctrine_Configurable
*/
public function setConfiguration(Doctrine_Configuration $config)
{
$this->_configuration = $config;
$this->_config = $config;
}
/* Configurable implementation */
public function hasAttribute($name)
/**
* Gets the COnfiguration used by the EntityManager.
*
* @return Configuration
*/
public function getConfiguration()
{
return isset($this->_attributes[$name]);
return $this->_config;
}
public function getAttribute($name)
{
if ( ! $this->hasAttribute($name)) {
throw Doctrine_EntityManager_Exception::unknownAttribute($name);
}
if ($this->_attributes[$name] === $this->_nullObject) {
return null;
}
return $this->_attributes[$name];
}
public function setAttribute($name, $value)
{
if ( ! $this->hasAttribute($name)) {
throw Doctrine_EntityManager_Exception::unknownAttribute($name);
}
// TODO: do some value checking depending on the attribute
$this->_attributes[$name] = $value;
}
}
?>
\ No newline at end of file
......@@ -132,7 +132,7 @@ abstract class Doctrine_EntityPersister_Abstract
if ($fk->isComposite()) {
$obj = $record->get($fk->getAlias());
if ($obj instanceof Doctrine_Entity &&
$obj->state() != Doctrine_Entity::STATE_LOCKED) {
$obj->_state() != Doctrine_Entity::STATE_LOCKED) {
$obj->delete($this->_mapper->getConnection());
}
}
......@@ -266,18 +266,18 @@ abstract class Doctrine_EntityPersister_Abstract
$conn = $this->_conn;
}
$state = $record->state();
$state = $record->_state();
if ($state === Doctrine_Entity::STATE_LOCKED) {
return false;
}
$record->state(Doctrine_Entity::STATE_LOCKED);
$record->_state(Doctrine_Entity::STATE_LOCKED);
try {
$conn->beginInternalTransaction();
$saveLater = $this->_saveRelated($record);
$record->state($state);
$record->_state($state);
if ($record->isValid()) {
$this->_insertOrUpdate($record);
......@@ -285,8 +285,8 @@ abstract class Doctrine_EntityPersister_Abstract
$conn->transaction->addInvalid($record);
}
$state = $record->state();
$record->state(Doctrine_Entity::STATE_LOCKED);
$state = $record->_state();
$record->_state(Doctrine_Entity::STATE_LOCKED);
foreach ($saveLater as $fk) {
$alias = $fk->getAlias();
......@@ -302,7 +302,7 @@ abstract class Doctrine_EntityPersister_Abstract
// save the MANY-TO-MANY associations
$this->saveAssociations($record);
// reset state
$record->state($state);
$record->_state($state);
$conn->commit();
} catch (Exception $e) {
$conn->rollback();
......@@ -322,7 +322,7 @@ abstract class Doctrine_EntityPersister_Abstract
$record->preSave();
$this->notifyEntityListeners($record, 'preSave', Doctrine_Event::RECORD_SAVE);
switch ($record->state()) {
switch ($record->_state()) {
case Doctrine_Entity::STATE_TDIRTY:
$this->_insert($record);
break;
......@@ -361,7 +361,7 @@ abstract class Doctrine_EntityPersister_Abstract
protected function _saveRelated(Doctrine_Entity $record)
{
$saveLater = array();
foreach ($record->getReferences() as $k => $v) {
foreach ($record->_getReferences() as $k => $v) {
$rel = $record->getTable()->getRelation($k);
$local = $rel->getLocal();
......@@ -408,7 +408,7 @@ abstract class Doctrine_EntityPersister_Abstract
*/
public function saveAssociations(Doctrine_Entity $record)
{
foreach ($record->getReferences() as $relationName => $relatedObject) {
foreach ($record->_getReferences() as $relationName => $relatedObject) {
if ($relatedObject === Doctrine_Null::$INSTANCE) {
continue;
}
......@@ -514,8 +514,8 @@ abstract class Doctrine_EntityPersister_Abstract
$table = $this->_classMetadata;
$state = $record->state();
$record->state(Doctrine_Entity::STATE_LOCKED);
$state = $record->_state();
$record->_state(Doctrine_Entity::STATE_LOCKED);
$this->_doDelete($record);
......
......@@ -138,7 +138,7 @@ class Doctrine_EntityPersister_JoinedSubclass extends Doctrine_EntityPersister_A
$conn->beginInternalTransaction();
$this->_deleteComposites($record);
$record->state(Doctrine_Entity::STATE_TDIRTY);
$record->_state(Doctrine_Entity::STATE_TDIRTY);
$identifier = $this->_convertFieldToColumnNames($record->identifier(), $class);
......@@ -149,7 +149,7 @@ class Doctrine_EntityPersister_JoinedSubclass extends Doctrine_EntityPersister_A
$this->_deleteRow($parentClass->getTableName(), $identifier);
}
$record->state(Doctrine_Entity::STATE_TCLEAN);
$record->_state(Doctrine_Entity::STATE_TCLEAN);
$this->removeRecord($record); // @todo should be done in the unitofwork
$conn->commit();
......
......@@ -44,11 +44,11 @@ class Doctrine_EntityPersister_Standard extends Doctrine_EntityPersister_Abstrac
$conn->beginInternalTransaction();
$this->_deleteComposites($record);
$record->state(Doctrine_Entity::STATE_TDIRTY);
$record->_state(Doctrine_Entity::STATE_TDIRTY);
$identifier = $this->_convertFieldToColumnNames($record->identifier(), $metadata);
$this->_deleteRow($metadata->getTableName(), $identifier);
$record->state(Doctrine_Entity::STATE_TCLEAN);
$record->_state(Doctrine_Entity::STATE_TCLEAN);
$this->removeRecord($record);
$conn->commit();
......
......@@ -29,7 +29,7 @@
* @package Doctrine
* @subpackage Event
* @link www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Event
......
<?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.phpdoctrine.org>.
*/
#namespace Doctrine::Common;
......
......@@ -48,7 +48,8 @@ class Doctrine_Formatter extends Doctrine_Connection_Module
*/
public function escapePattern($text)
{
if ( ! $this->string_quoting['escape_pattern']) {
return $text;
/*if ( ! $this->string_quoting['escape_pattern']) {
return $text;
}
$tmp = $this->conn->string_quoting;
......@@ -60,7 +61,7 @@ class Doctrine_Formatter extends Doctrine_Connection_Module
foreach ($this->wildcards as $wildcard) {
$text = str_replace($wildcard, $tmp['escape_pattern'] . $wildcard, $text);
}
return $text;
return $text;*/
}
/**
......
......@@ -76,7 +76,7 @@ class Doctrine_Hydrator_RecordDriver
$relatedClass = $relation->getTable();
$coll = $this->getElementCollection($relatedClass->getClassName());
$coll->setReference($entity, $relation);
$entity->rawSetReference($name, $coll);
$entity->_rawSetReference($name, $coll);
$this->_initializedRelations[$entity->getOid()][$name] = true;
}
}
......@@ -99,23 +99,23 @@ class Doctrine_Hydrator_RecordDriver
public function addRelatedIndexedElement(Doctrine_Entity $entity1, $property,
Doctrine_Entity $entity2, $indexField)
{
$entity1->rawGetReference($property)->add($entity2, $entity2->rawGetField($indexField));
$entity1->_rawGetReference($property)->add($entity2, $entity2->_rawGetField($indexField));
}
public function addRelatedElement(Doctrine_Entity $entity1, $property,
Doctrine_Entity $entity2)
{
$entity1->rawGetReference($property)->add($entity2);
$entity1->_rawGetReference($property)->add($entity2);
}
public function setRelatedElement(Doctrine_Entity $entity1, $property, $entity2)
{
$entity1->rawSetReference($property, $entity2);
$entity1->_rawSetReference($property, $entity2);
}
public function isIndexKeyInUse(Doctrine_Entity $entity, $assocField, $indexField)
{
return $entity->rawGetReference($assocField)->contains($indexField);
return $entity->_rawGetReference($assocField)->contains($indexField);
}
public function isFieldSet(Doctrine_Entity $entity, $field)
......@@ -125,17 +125,17 @@ class Doctrine_Hydrator_RecordDriver
public function getFieldValue(Doctrine_Entity $entity, $field)
{
return $entity->rawGetField($field);
return $entity->_rawGetField($field);
}
public function getReferenceValue(Doctrine_Entity $entity, $field)
{
return $entity->rawGetReference($field);
return $entity->_rawGetReference($field);
}
public function addElementToIndexedCollection($coll, $entity, $keyField)
{
$coll->add($entity, $entity->rawGetField($keyField));
$coll->add($entity, $entity->_rawGetField($keyField));
}
public function addElementToCollection($coll, $entity)
......
......@@ -71,7 +71,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
* @param array $tableAliases Array that maps table aliases (SQL alias => DQL alias)
* @param array $aliasMap Array that maps DQL aliases to their components
* (DQL alias => array(
* 'table' => Table object,
* 'metadata' => Table object,
* 'parent' => Parent DQL alias (if any),
* 'relation' => Relation object (if any),
* 'map' => Custom index to use as the key in the result (if any),
......@@ -109,7 +109,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
// Used variables during hydration
reset($this->_queryComponents);
$rootAlias = key($this->_queryComponents);
$rootComponentName = $this->_queryComponents[$rootAlias]['table']->getClassName();
$rootComponentName = $this->_queryComponents[$rootAlias]['metadata']->getClassName();
// if only one class is involved we can make our lives easier
$isSimpleQuery = count($this->_queryComponents) <= 1;
// Lookup map to quickly discover/lookup existing records in the result
......@@ -138,8 +138,8 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
// Initialize
foreach ($this->_queryComponents as $dqlAlias => $component) {
// disable lazy-loading of related elements during hydration
$component['table']->setAttribute(Doctrine::ATTR_LOAD_REFERENCES, false);
$componentName = $component['table']->getClassName();
$component['metadata']->setAttribute('loadReferences', false);
$componentName = $component['metadata']->getClassName();
$identifierMap[$dqlAlias] = array();
$resultPointers[$dqlAlias] = array();
$idTemplate[$dqlAlias] = '';
......@@ -170,7 +170,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
//
// hydrate the data of the root entity from the current row
//
$class = $this->_queryComponents[$rootAlias]['table'];
$class = $this->_queryComponents[$rootAlias]['metadata'];
$componentName = $class->getComponentName();
// Check for an existing element
......@@ -180,17 +180,10 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
// do we need to index by a custom field?
if ($field = $this->_getCustomIndexField($rootAlias)) {
// TODO: must be checked in the parser. fields used in INDEXBY
// must be a) the primary key or b) unique & notnull
/*if (isset($result[$field])) {
throw Doctrine_Hydrator_Exception::nonUniqueKeyMapping();
} else if ( ! isset($element[$field])) {
throw Doctrine_Hydrator_Exception::nonExistantFieldUsedAsIndex($field);
}*/
if ($parserResult->isMixedQuery()) {
$result[] = array(
$driver->getFieldValue($element, $field) => $element
);
$driver->getFieldValue($element, $field) => $element
);
} else {
$driver->addElementToIndexedCollection($result, $element, $field);
}
......@@ -220,7 +213,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
foreach ($rowData as $dqlAlias => $data) {
$index = false;
$map = $this->_queryComponents[$dqlAlias];
$componentName = $map['table']->getClassName();
$componentName = $map['metadata']->getClassName();
$parent = $map['parent'];
$relation = $map['relation'];
$relationAlias = $relation->getAlias();
......@@ -258,7 +251,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
}
} else if ( ! isset($baseElement[$relationAlias])) {
$driver->setRelatedElement($baseElement, $relationAlias,
$driver->getNullPointer());
$driver->getElementCollection($componentName));
}
} else {
// x-1 relation
......@@ -290,7 +283,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
// re-enable lazy loading
foreach ($this->_queryComponents as $dqlAlias => $data) {
$data['table']->setAttribute(Doctrine::ATTR_LOAD_REFERENCES, true);
$data['metadata']->setAttribute('loadReferences', true);
}
$e = microtime(true);
......@@ -370,7 +363,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
$e = explode('__', $key);
$columnName = strtolower(array_pop($e));
$cache[$key]['dqlAlias'] = $this->_tableAliases[strtolower(implode('__', $e))];
$classMetadata = $this->_queryComponents[$cache[$key]['dqlAlias']]['table'];
$classMetadata = $this->_queryComponents[$cache[$key]['dqlAlias']]['metadata'];
// check whether it's an aggregate value or a regular field
if (isset($this->_queryComponents[$cache[$key]['dqlAlias']]['agg'][$columnName])) {
$fieldName = $this->_queryComponents[$cache[$key]['dqlAlias']]['agg'][$columnName];
......@@ -399,7 +392,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
}
}
$class = $this->_queryComponents[$cache[$key]['dqlAlias']]['table'];
$class = $this->_queryComponents[$cache[$key]['dqlAlias']]['metadata'];
$dqlAlias = $cache[$key]['dqlAlias'];
$fieldName = $cache[$key]['fieldName'];
......@@ -454,7 +447,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
$e = explode('__', $key);
$columnName = strtolower(array_pop($e));
$cache[$key]['dqlAlias'] = $this->_tableAliases[strtolower(implode('__', $e))];
$classMetadata = $this->_queryComponents[$cache[$key]['dqlAlias']]['table'];
$classMetadata = $this->_queryComponents[$cache[$key]['dqlAlias']]['metadata'];
// check whether it's an aggregate value or a regular field
if (isset($this->_queryComponents[$cache[$key]['dqlAlias']]['agg'][$columnName])) {
$fieldName = $this->_queryComponents[$cache[$key]['dqlAlias']]['agg'][$columnName];
......@@ -476,7 +469,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
}
}
$class = $this->_queryComponents[$cache[$key]['dqlAlias']]['table'];
$class = $this->_queryComponents[$cache[$key]['dqlAlias']]['metadata'];
$dqlAlias = $cache[$key]['dqlAlias'];
$fieldName = $cache[$key]['fieldName'];
......
......@@ -76,7 +76,7 @@ class Doctrine_Lib
$r[] = '<pre>';
$r[] = 'Component : ' . $record->getTable()->getComponentName();
$r[] = 'ID : ' . $record->obtainIdentifier();
$r[] = 'References : ' . count($record->getReferences());
$r[] = 'References : ' . count($record->_getReferences());
$r[] = 'State : ' . Doctrine_Lib::getRecordStateAsString($record->getState());
$r[] = 'OID : ' . $record->getOID();
$r[] = 'data : ' . Doctrine::dump($record->getData(), false);
......
......@@ -154,7 +154,6 @@ class Doctrine_Query_Parser
$isMatch = ($this->lookahead['type'] === $token);
}
if ( ! $isMatch) {
// No definition for value checking.
$this->syntaxError($this->_keywordTable->getLiteral($token));
......
......@@ -27,7 +27,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Printer
......
......@@ -148,28 +148,6 @@ abstract class Doctrine_Query_Production
return new $class($this->_parser);
}
/**
* Executes a production with specified name and parameters.
*
* @param string $name production name
* @param array $params an associative array containing parameter names and
* their values
* @return mixed
*/
public function __call($method, $args)
{
if (substr($method, 0, 3) === 'get') {
$var = '_' . substr($method, 3);
$var[1] = strtolower($var[1]);
return $this->$var;
}
return null;
}
/**
* Executes this production using the specified parameters.
*
......@@ -233,4 +211,9 @@ abstract class Doctrine_Query_Production
public function semantical($paramHolder)
{
}
public function getParser()
{
return $this->_parser;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_AggregateExpression extends Doctrine_Query_Production
......@@ -87,4 +87,32 @@ class Doctrine_Query_Production_AggregateExpression extends Doctrine_Query_Produ
. $this->_expression->buildSql()
. ')';
}
/**
* Visitor support.
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_expression->accept($visitor);
$visitor->visitAggregateExpression($this);
}
/* Getters */
public function getExpression()
{
return $this->_expression;
}
public function getFunctionName()
{
return $this->_functionName;
}
public function isDistinct()
{
return $this->_isDistinct;
}
}
......@@ -86,10 +86,33 @@ class Doctrine_Query_Production_Atom extends Doctrine_Query_Production
break;
default:
return $conn->string_quoting['start']
$stringQuoting = $conn->getProperty('string_quoting');
return $stringQuoting['start']
. $conn->quote($this->_value, $this->_type)
. $conn->string_quoting['end'];
. $stringQuoting['end'];
break;
}
}
/**
* Visitor support.
*
* @param object $visitor
*/
public function accept($visitor)
{
$visitor->visitAtom($this);
}
/* Getters */
public function getType()
{
return $this->_type;
}
public function getValue()
{
return $this->_value;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_BetweenExpression extends Doctrine_Query_Production
......@@ -65,4 +65,33 @@ class Doctrine_Query_Production_BetweenExpression extends Doctrine_Query_Product
return (($this->_not) ? 'NOT ' : '') . 'BETWEEN '
. $this->_fromExpression->buildSql() . ' AND ' . $this->_toExpression->buildSql();
}
/**
* Visitor support.
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_fromExpression->accept($visitor);
$this->_toExpression->accept($visitor);
$visitor->visitBetweenExpression($this);
}
/* Getters */
public function isNot()
{
return $this->_not;
}
public function getFromExpression()
{
return $this->_fromExpression;
}
public function getToExpression()
{
return $this->_toExpression;
}
}
......@@ -27,7 +27,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_ComparisonExpression extends Doctrine_Query_Production
......@@ -65,11 +65,38 @@ class Doctrine_Query_Production_ComparisonExpression extends Doctrine_Query_Prod
}
}
public function buildSql()
{
return $this->_operator . ' ' . (($this->_isSubselect) ?
'(' . $this->_expression->buildSql() . ')' : $this->_expression->buildSql()
);
}
/**
* Visitor support.
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_expression->accept($visitor);
$visitor->visitComparisonExpression($this);
}
/* Getters */
public function getOperator()
{
return $this->_operator;
}
public function getExpression()
{
return $this->_expression;
}
public function isSubselect()
{
return $this->_isSubselect;
}
}
......@@ -27,7 +27,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_ComparisonOperator extends Doctrine_Query_Production
......@@ -78,4 +78,14 @@ class Doctrine_Query_Production_ComparisonOperator extends Doctrine_Query_Produc
break;
}
}
/**
* Visitor support.
*
* @param object $visitor
*/
public function accept($visitor)
{
$visitor->visitComparisonOperator($this);
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_ConditionalExpression extends Doctrine_Query_Production
......@@ -69,4 +69,24 @@ class Doctrine_Query_Production_ConditionalExpression extends Doctrine_Query_Pro
{
return $value->buildSql();
}
/**
* Visitor support.
*
* @param object $visitor
*/
public function accept($visitor)
{
foreach ($this->_conditionalTerms as $term) {
$term->accept($visitor);
}
$visitor->visitConditionalExpression($this);
}
/* Getters */
public function getConditionalTerms()
{
return $this->_conditionalTerms;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_ConditionalFactor extends Doctrine_Query_Production
......@@ -60,4 +60,22 @@ class Doctrine_Query_Production_ConditionalFactor extends Doctrine_Query_Product
// Do not need to check $notFactor. It'll be always present if we have this instance.
return 'NOT ' . $this->_conditionalPrimary->buildSql();
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_conditionalPrimary->accept($visitor);
$visitor->visitConditionalFactor($this);
}
/* Getters */
public function getConditionalPrimary()
{
return $this->_conditionalPrimary;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_ConditionalPrimary extends Doctrine_Query_Production
......@@ -98,4 +98,10 @@ class Doctrine_Query_Production_ConditionalPrimary extends Doctrine_Query_Produc
return false;
}
public function accept($visitor)
{
$this->_conditionalExpression->accept($visitor);
$visitor->visitConditionalPrimary($this);
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_ConditionalTerm extends Doctrine_Query_Production
......@@ -69,4 +69,24 @@ class Doctrine_Query_Production_ConditionalTerm extends Doctrine_Query_Productio
{
return $value->buildSql();
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
foreach ($this->_conditionalFactors as $factor) {
$factor->accept($visitor);
}
$visitor->visitConditionalTerm($this);
}
/* Getters */
public function getConditionalFactors()
{
return $this->_conditionalFactors;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_DeleteClause extends Doctrine_Query_Production
......@@ -48,9 +48,26 @@ class Doctrine_Query_Production_DeleteClause extends Doctrine_Query_Production
$this->_variableDeclaration = $this->AST('VariableDeclaration', $paramHolder);
}
public function buildSql()
{
return 'DELETE FROM ' . $this->_variableDeclaration->buildSql();
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_variableDeclaration->accept($visitor);
$visitor->visitDeleteClause($this);
}
/* Getters */
public function getVariableDeclaration()
{
return $this->_variableDeclaration;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_DeleteStatement extends Doctrine_Query_Production
......@@ -56,4 +56,30 @@ class Doctrine_Query_Production_DeleteStatement extends Doctrine_Query_Productio
return $this->_deleteClause->buildSql() . (($this->_whereClause !== null)
? ' ' . $this->_whereClause->buildSql() : ' WHERE 1 = 1');
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_deleteClause->accept($visitor);
if ($this->_whereClause) {
$this->_whereClause->accept($visitor);
}
$visitor->visitDeleteStatement($this);
}
/* Getters */
public function getDeleteClause()
{
return $this->_deleteClause;
}
public function getWhereClause()
{
return $this->_whereClause;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_ExistsExpression extends Doctrine_Query_Production
......@@ -51,4 +51,22 @@ class Doctrine_Query_Production_ExistsExpression extends Doctrine_Query_Producti
{
return 'EXISTS (' . $this->_subselect->buildSql() . ')';
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_subselect->accept($visitor);
$visitor->visitExistsExpression($this);
}
/* Getters */
public function getSubselect()
{
return $this->_subselect;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_Expression extends Doctrine_Query_Production
......@@ -86,4 +86,24 @@ class Doctrine_Query_Production_Expression extends Doctrine_Query_Production
{
return (is_string($value) ? $value : $value->buildSql());
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
foreach ($this->_terms as $term) {
$term->accept($visitor);
}
$visitor->visitExpression($this);
}
/* Getters */
public function getTerms()
{
return $this->_terms;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_Factor extends Doctrine_Query_Production
......@@ -68,4 +68,27 @@ class Doctrine_Query_Production_Factor extends Doctrine_Query_Production
{
return $this->_type . ' ' . $this->_primary->buildSql();
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_primary->accept($visitor);
$visitor->visitFactor($this);
}
/* Getters */
public function getType()
{
return $this->_type;
}
public function getPrimary()
{
return $this->_primary;
}
}
......@@ -27,7 +27,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_FieldIdentificationVariable extends Doctrine_Query_Production
......@@ -74,4 +74,26 @@ class Doctrine_Query_Production_FieldIdentificationVariable extends Doctrine_Que
$this->_columnAlias = $parserResult->getTableAliasFromComponentAlias($componentAlias)
. Doctrine_Query_Production::SQLALIAS_SEPARATOR . $idx;
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$visitor->visitFieldIdentificationVariable($this);
}
/* Getters */
public function getFieldAlias()
{
return $this->_fieldAlias;
}
public function getColumnAlias()
{
return $this->_columnAlias;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_FromClause extends Doctrine_Query_Production
......@@ -71,4 +71,24 @@ class Doctrine_Query_Production_FromClause extends Doctrine_Query_Production
{
return $value->buildSql();
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
foreach ($this->_identificationVariableDeclaration as $decl) {
$decl->accept($visitor);
}
$visitor->visitFromClause($this);
}
/* Getters */
public function getIdentificationVariableDeclarations()
{
return $this->_identificationVariableDeclaration;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_Function extends Doctrine_Query_Production
......@@ -76,4 +76,29 @@ class Doctrine_Query_Production_Function extends Doctrine_Query_Production
{
return $value->buildSql();
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
foreach ($this->_arguments as $argument) {
$argument->accept($visitor);
}
$visitor->visitFunction($this);
}
/* Getters */
public function getFunctionName()
{
return $this->_functionName;
}
public function getArguments()
{
return $this->_arguments;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_GroupByClause extends Doctrine_Query_Production
......@@ -66,4 +66,24 @@ class Doctrine_Query_Production_GroupByClause extends Doctrine_Query_Production
{
return $value->buildSql();
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
foreach ($this->_groupByItems as $item) {
$item->accept($visitor);
}
$visitor->visitGroupByClause($this);
}
/* Getters */
public function getGroupByItems()
{
return $this->_groupByItems;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_GroupByItem extends Doctrine_Query_Production
......@@ -37,4 +37,14 @@ class Doctrine_Query_Production_GroupByItem extends Doctrine_Query_Production
{
return $this->AST('PathExpression', $paramHolder);
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$visitor->visitGroupByItem($this);
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_HavingClause extends Doctrine_Query_Production
......@@ -49,4 +49,22 @@ class Doctrine_Query_Production_HavingClause extends Doctrine_Query_Production
{
return 'HAVING ' . $this->_conditionalExpression->buildSql();
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_conditionalExpression->accept($visitor);
$visitor->visitHavingClause($this);
}
/* Getters */
public function getConditionalExpression()
{
return $this->_conditionalExpression;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_IdentificationVariable extends Doctrine_Query_Production
......@@ -62,4 +62,21 @@ class Doctrine_Query_Production_IdentificationVariable extends Doctrine_Query_Pr
return $this->_componentAlias;
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$visitor->visitIdentificationVariable($this);
}
/* Getters */
public function getComponentAlias()
{
return $this->_componentAlias;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_IdentificationVariableDeclaration extends Doctrine_Query_Production
......@@ -92,4 +92,43 @@ class Doctrine_Query_Production_IdentificationVariableDeclaration extends Doctri
return $str;
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_rangeVariableDeclaration->accept($visitor);
if ($this->_indexBy) {
$this->_indexBy->accept($visitor);
}
foreach ($this->_relations as $relation) {
if ($relation['join']) {
$relation['join']->accept($visitor);
}
if ($relation['indexby']) {
$relation['indexby']->accept($visitor);
}
}
$visitor->visitIdentificationVariable($this);
}
/* Getters */
public function getRangeVariableDeclaration()
{
return $this->_rangeVariableDeclaration;
}
public function getIndexBy()
{
return $this->_indexBy;
}
public function getRelations()
{
return $this->_relations;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_InExpression extends Doctrine_Query_Production
......@@ -87,4 +87,38 @@ class Doctrine_Query_Production_InExpression extends Doctrine_Query_Production
{
return $value->buildSql();
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
if ($this->_subselect !== null) {
$this->_subselect->accept($visitor);
} else {
foreach ($this->_atoms as $atom) {
$atom->accept($visitor);
}
}
$visitor->visitInExpression($this);
}
/* Getters */
public function isNot()
{
return $this->_not;
}
public function getSubselect()
{
return $this->_subselect;
}
public function getAtoms()
{
return $this->_atoms;
}
}
......@@ -27,7 +27,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_IndexBy extends Doctrine_Query_Production
......@@ -105,4 +105,26 @@ class Doctrine_Query_Production_IndexBy extends Doctrine_Query_Production
{
return '';
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$visitor->visitIndexBy($this);
}
/* Getters */
public function getComponentAlias()
{
return $this->_componentAlias;
}
public function getFieldName()
{
return $this->_fieldName;
}
}
......@@ -27,7 +27,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_Join extends Doctrine_Query_Production
......@@ -76,4 +76,36 @@ class Doctrine_Query_Production_Join extends Doctrine_Query_Production
{
return '';
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$visitor->visitJoin($this);
}
/* Getters */
public function getJoinType()
{
return $this->_joinType;
}
public function getRangeVariableDeclaration()
{
return $this->_rangeVariableDeclaration;
}
public function getWhereType()
{
return $this->_whereType;
}
public function getConditionalExpression()
{
return $this->_conditionalExpression;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_LikeExpression extends Doctrine_Query_Production
......@@ -69,4 +69,32 @@ class Doctrine_Query_Production_LikeExpression extends Doctrine_Query_Production
return (($this->_not) ? 'NOT ' : '') . 'LIKE ' . $this->_expression->buildSql()
. (($this->_escapeString !== null) ? ' ESCAPE ' . $this->_escapeString : '');
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_expression->accept($visitor);
$visitor->visitLikeExpression($this);
}
/* Getters */
public function isNot()
{
return $this->_not;
}
public function getExpression()
{
return $this->_expression;
}
public function getEscapeString()
{
return $this->_escapeString;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_LimitClause extends Doctrine_Query_Production
......@@ -45,4 +45,21 @@ class Doctrine_Query_Production_LimitClause extends Doctrine_Query_Production
return $this;
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$visitor->visitLimitClause($this);
}
/* Getters */
public function getLimit()
{
return $this->_limit;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_NullComparisonExpression extends Doctrine_Query_Production
......@@ -55,4 +55,21 @@ class Doctrine_Query_Production_NullComparisonExpression extends Doctrine_Query_
{
return 'IS ' . (($this->_not) ? 'NOT ' : '') . 'NULL';
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$visitor->visitNullComparisonExpression($this);
}
/* Getters */
public function isNot()
{
return $this->_not;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_OffsetClause extends Doctrine_Query_Production
......@@ -54,4 +54,21 @@ class Doctrine_Query_Production_OffsetClause extends Doctrine_Query_Production
// SelectStatement, not this object's one.
return ' OFFSET ' . $this->_offset;
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$visitor->visitOffsetClause($this);
}
/* Getters */
public function getOffset()
{
return $this->_offset;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_OrderByClause extends Doctrine_Query_Production
......@@ -65,4 +65,24 @@ class Doctrine_Query_Production_OrderByClause extends Doctrine_Query_Production
return $str;
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
foreach ($this->_orderByItems as $item) {
$item->accept($visitor);
}
$visitor->visitOrderByClause($this);
}
/* Getters */
public function getOrderByItems()
{
return $this->_orderByItems;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_OrderByItem extends Doctrine_Query_Production
......@@ -56,4 +56,27 @@ class Doctrine_Query_Production_OrderByItem extends Doctrine_Query_Production
{
return $this->_expression->buildSql() . ' ' . $this->_orderType;
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_expression->accept($visitor);
$visitor->visitOrderByItem($this);
}
/* Getters */
public function getExpression()
{
return $this->_expression;
}
public function getOrderType()
{
return $this->_orderType;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_PathExpression extends Doctrine_Query_Production
......@@ -142,4 +142,31 @@ class Doctrine_Query_Production_PathExpression extends Doctrine_Query_Production
return $conn->quoteIdentifier($str);
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$visitor->visitPathExpression($this);
}
/* Getters */
public function getIdentifiers()
{
return $this->_identifiers;
}
public function getFieldName()
{
return $this->_fieldName;
}
public function getComponentAlias()
{
return $this->_componentAlias;
}
}
......@@ -27,7 +27,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_PathExpressionEndingWithAsterisk extends Doctrine_Query_Production
......@@ -154,4 +154,26 @@ class Doctrine_Query_Production_PathExpressionEndingWithAsterisk extends Doctrin
return $str;
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$visitor->visitPathExpressionEndingWithAsterisk($this);
}
/* Getters */
public function getIdentifiers()
{
return $this->_identifiers;
}
public function getQueryComponent()
{
return $this->_queryComponent;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_Primary extends Doctrine_Query_Production
......@@ -88,4 +88,23 @@ class Doctrine_Query_Production_Primary extends Doctrine_Query_Production
{
return '(' . $this->_expression->buildSql() . ')';
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_expression->accept($visitor);
$visitor->visitPrimary($this);
}
/* Getters */
public function getExpression()
{
return $this->_expression;
}
}
......@@ -27,7 +27,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_QuantifiedExpression extends Doctrine_Query_Production
......@@ -69,4 +69,27 @@ class Doctrine_Query_Production_QuantifiedExpression extends Doctrine_Query_Prod
{
return $this->_type . ' (' . $this->_subselect->buildSql() . ')';
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_subselect->accept($visitor);
$visitor->visitQuantifiedExpression($this);
}
/* Getters */
public function getType()
{
return $this->_type;
}
public function getSubselect()
{
return $this->_subselect;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_QueryLanguage extends Doctrine_Query_Production
......
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_RangeVariableDeclaration extends Doctrine_Query_Production
......@@ -235,4 +235,26 @@ class Doctrine_Query_Production_RangeVariableDeclaration extends Doctrine_Query_
$parserResult->setQueryComponent($this->_identificationVariable, $queryComponent);
$parserResult->setTableAlias($tableAlias, $this->_identificationVariable);
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$visitor->visitRangeVariableDeclaration($this);
}
/* Getters */
public function getIdentifiers()
{
return $this->_identifiers;
}
public function getIdentificationVariable()
{
return $this->_identificationVariable;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_SelectClause extends Doctrine_Query_Production
......@@ -85,4 +85,29 @@ class Doctrine_Query_Production_SelectClause extends Doctrine_Query_Production
{
return $value->buildSql();
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
foreach ($this->_selectExpressions as $expression) {
$expression->accept($visitor);
}
$visitor->visitSelectClause($this);
}
/* Getters */
public function isDistinct()
{
return $this->_isDistinct;
}
public function getSelectExpressions()
{
return $this->_selectExpressions;
}
}
......@@ -53,7 +53,7 @@ class Doctrine_Query_Production_SelectExpression extends Doctrine_Query_Producti
$this->_leftExpression = $this->AST('PathExpressionEndingWithAsterisk', $paramHolder);
$fieldName = implode('.', $this->_leftExpression->getIdentifiers()) . '.*';
} elseif(($this->_isSubselect = $this->_isSubselect()) === true) {
} else if (($this->_isSubselect = $this->_isSubselect()) === true) {
$this->_parser->match('(');
$this->_leftExpression = $this->AST('Subselect', $paramHolder);
$this->_parser->match(')');
......@@ -87,14 +87,16 @@ class Doctrine_Query_Production_SelectExpression extends Doctrine_Query_Producti
$parserResult = $this->_parser->getParserResult();
// We cannot have aliases for foo.*
if ($this->_leftExpression instanceof Doctrine_Query_Production_PathExpressionEndingWithAsterisk && $this->_fieldIdentificationVariable !== null) {
if ($this->_leftExpression instanceof Doctrine_Query_Production_PathExpressionEndingWithAsterisk
&& $this->_fieldIdentificationVariable !== null) {
$this->_parser->semanticalError(
"Cannot assign an identification variable to a path expression ending with asterisk (ie. foo.bar.* AS foobaz)."
);
}
// Also, we cannot have aliases for path expressions: foo.bar
if ($this->_leftExpression instanceof Doctrine_Query_Production_PathExpressionEndingWithAsterisk && $this->_fieldIdentificationVariable !== null) {
if ($this->_leftExpression instanceof Doctrine_Query_Production_PathExpressionEndingWithAsterisk
&& $this->_fieldIdentificationVariable !== null) {
$this->_parser->semanticalError(
"Cannot assign an identification variable to a path expression (ie. foo.bar AS foobaz)."
);
......
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_SelectStatement extends Doctrine_Query_Production
......@@ -93,4 +93,60 @@ class Doctrine_Query_Production_SelectStatement extends Doctrine_Query_Productio
. (($this->_havingClause !== null) ? ' ' . $this->_havingClause->buildSql() : '')
. (($this->_orderByClause !== null) ? ' ' . $this->_orderByClause->buildSql() : '');
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_selectClause->accept($visitor);
$this->_fromClause->accept($visitor);
if ($this->_whereClause) {
$this->_whereClause->accept($visitor);
}
if ($this->_groupByClause) {
$this->_groupByClause->accept($visitor);
}
if ($this->_havingClause) {
$this->_havingClause->accept($visitor);
}
if ($this->_orderByClause) {
$this->_orderByClause->accept($visitor);
}
$visitor->visitSelectStatement($this);
}
/* Getters */
public function getSelectClause()
{
return $this->_selectClause;
}
public function getFromClause()
{
return $this->_fromClause;
}
public function getWhereClause()
{
return $this->_whereClause;
}
public function getGroupByClause()
{
return $this->_groupByClause;
}
public function getHavingClause()
{
return $this->_havingClause;
}
public function getOrderByClause()
{
return $this->_orderByClause;
}
}
......@@ -30,7 +30,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_SimpleConditionalExpression extends Doctrine_Query_Production
......@@ -106,4 +106,28 @@ class Doctrine_Query_Production_SimpleConditionalExpression extends Doctrine_Que
return $token['type'];
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_leftExpression->accept($visitor);
$this->_rightExpression->accept($visitor);
$visitor->visitSimpleConditionalExpression($this);
}
/* Getters */
public function getLeftExpression()
{
return $this->_leftExpression;
}
public function getRightExpression()
{
return $this->_rightExpression;
}
}
......@@ -27,7 +27,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_SimpleSelectClause extends Doctrine_Query_Production
......@@ -65,4 +65,27 @@ class Doctrine_Query_Production_SimpleSelectClause extends Doctrine_Query_Produc
return 'SELECT ' . (($this->_isDistinct) ? 'DISTINCT ' : '')
. $this->_selectExpression->buildSql();
}
/**
* Visitor support
*
* @param object $visitor
*/
public function acccept($visitor)
{
$this->_selectExpression->accept($visitor);
$visitor->visitSimpleSelectClause($this);
}
/* Getters */
public function isDistinct()
{
return $this->_isDistinct;
}
public function getSelectExpression()
{
return $this->_selectExpression;
}
}
......@@ -29,7 +29,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_Subselect extends Doctrine_Query_Production
......@@ -101,5 +101,61 @@ class Doctrine_Query_Production_Subselect extends Doctrine_Query_Production
. (($this->_havingClause !== null) ? ' ' . $this->_havingClause->buildSql() : '')
. (($this->_orderByClause !== null) ? ' ' . $this->_orderByClause->buildSql() : '');
}
/**
* Visitor support
*
* @param object $visitor
*/
public function accept($visitor)
{
$this->_simpleSelectClause->accept($visitor);
$this->_fromClause->accept($visitor);
if ($this->_whereClause) {
$this->_whereClause->accept($visitor);
}
if ($this->_groupByClause) {
$this->_groupByClause->accept($visitor);
}
if ($this->_havingClause) {
$this->_havingClause->accept($visitor);
}
if ($this->_orderByClause) {
$this->_orderByClause->accept($visitor);
}
$visitor->visitSubselect($this);
}
/* Getters */
public function getSimpleSelectClause()
{
return $this->_simpleSelectClause;
}
public function getFromClause()
{
return $this->_fromClause;
}
public function getWhereClause()
{
return $this->_whereClause;
}
public function getGroupByClause()
{
return $this->_groupByClause;
}
public function getHavingClause()
{
return $this->_havingClause;
}
public function getOrderByClause()
{
return $this->_orderByClause;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_Term extends Doctrine_Query_Production
......@@ -86,4 +86,22 @@ class Doctrine_Query_Production_Term extends Doctrine_Query_Production
{
return (is_string($value) ? $value : $value->buildSql());
}
/**
* Visitor support.
*/
public function accept($visitor)
{
foreach ($this->_factors as $factor) {
$factor->accept($visitor);
}
$visitor->visitTerm($this);
}
/* Getters */
public function getFactors()
{
return $this->_factors;
}
}
......@@ -74,4 +74,28 @@ class Doctrine_Query_Production_UpdateClause extends Doctrine_Query_Production
{
return $value->buildSql();
}
/**
* Visitor support.
*/
public function accept($visitor)
{
$this->_variableDeclaration->accept($visitor);
foreach ($this->_updateItems as $item) {
$item->accept($visitor);
}
$visitor->visitUpdateClause($this);
}
/* Getters */
public function getVariableDeclaration()
{
return $this->_variableDeclaration;
}
public function getUpdateItems()
{
return $this->_updateItems;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_UpdateItem extends Doctrine_Query_Production
......@@ -59,4 +59,28 @@ class Doctrine_Query_Production_UpdateItem extends Doctrine_Query_Production
return $this->_pathExpression->buildSql() . ' = '
. ($this->_expression === null ? 'NULL' : $this->_expression->buildSql());
}
/**
* Visitor support.
*/
public function accept($visitor)
{
$this->_pathExpression->accept($visitor);
if ($this->_expression) {
$this->_expression->accept($visitor);
}
$visitor->visitUpdateItem($this);
}
/* Getters */
public function getPathExpression()
{
return $this->_pathExpression;
}
public function getExpression()
{
return $this->_expression;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_UpdateStatement extends Doctrine_Query_Production
......@@ -56,4 +56,28 @@ class Doctrine_Query_Production_UpdateStatement extends Doctrine_Query_Productio
return $this->_updateClause->buildSql() . (($this->_whereClause !== null)
? ' ' . $this->_whereClause->buildSql() : ' WHERE 1 = 1');
}
/**
* Visitor support.
*/
public function accept($visitor)
{
$this->_updateClause->accept($visitor);
if ($this->_whereClause) {
$this->_whereClause->accept($visitor);
}
$visitor->visitUpdateStatment($this);
}
/* Getters */
public function getUpdateClause()
{
return $this->_updateClause;
}
public function getWhereClause()
{
return $this->_whereClause;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_VariableDeclaration extends Doctrine_Query_Production
......@@ -130,4 +130,24 @@ class Doctrine_Query_Production_VariableDeclaration extends Doctrine_Query_Produ
return $conn->quoteIdentifier($queryComponent['metadata']->getTableName()) . ' '
. $conn->quoteIdentifier($parserResult->getTableAliasFromComponentAlias($this->_componentAlias));
}
/**
* Visitor support.
*/
public function accept($visitor)
{
$visitor->visitVariableDeclaration($this);
}
/* Getters */
public function getComponentName()
{
return $this->_componentName;
}
public function getComponentAlias()
{
return $this->_componentAlias;
}
}
......@@ -28,7 +28,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Production_WhereClause extends Doctrine_Query_Production
......@@ -49,4 +49,20 @@ class Doctrine_Query_Production_WhereClause extends Doctrine_Query_Production
{
return 'WHERE ' . $this->_conditionalExpression->buildSql();
}
/**
* Visitor support.
*/
public function accept($visitor)
{
$this->_conditionalExpression->accept($visitor);
$visitor->visitWhereClause($this);
}
/* Getters */
public function getConditionalExpression()
{
return $this->_conditionalExpression;
}
}
......@@ -29,7 +29,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_ProductionParamHolder
......
......@@ -27,7 +27,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_Scanner
......@@ -150,7 +150,7 @@ class Doctrine_Query_Scanner
// World number: 1.000.000,02 or -1,234e-2
$worldnum = strtr($value, array('.' => '', ',' => '.'));
if(is_numeric($worldnum)) {
if (is_numeric($worldnum)) {
return $worldnum;
}
......
This diff is collapsed.
......@@ -36,6 +36,13 @@ class Doctrine_Query_SqlExecutor_SingleTableDeleteUpdate extends Doctrine_Query_
public function __construct(Doctrine_Query_Production $AST)
{
parent::__construct($AST);
/*if ($AST instanceof Doctrine_Query_Production_DeleteStatement) {
$builder = new Doctrine_Query_SqlBuilder_MySql(Doctrine_EntityManagerFactory::getManager());
$AST->accept($builder);
echo PHP_EOL . "SQL:" . $builder->getSql() . PHP_EOL . PHP_EOL;
}*/
$this->_sqlStatements = $AST->buildSql();
}
......
......@@ -27,7 +27,7 @@
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
final class Doctrine_Query_Token
......
......@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Relation');
/**
* Doctrine_Relation_LocalKey
* This class represents a local key relation
......
......@@ -10,9 +10,10 @@ require_once 'Orm/Component/AllTests.php';
require_once 'Orm/Query/AllTests.php';
require_once 'Orm/Hydration/AllTests.php';
require_once 'Orm/Ticket/AllTests.php';
require_once 'Orm/Entity/AllTests.php';
// Tests
require_once 'Orm/UnitOfWorkTestCase.php';
require_once 'Orm/UnitOfWorkTest.php';
require_once 'Orm/EntityManagerFactoryTest.php';
class Orm_AllTests
......@@ -26,13 +27,14 @@ class Orm_AllTests
{
$suite = new Doctrine_OrmTestSuite('Doctrine Orm');
$suite->addTestSuite('Orm_UnitOfWorkTestCase');
$suite->addTestSuite('Orm_UnitOfWorkTest');
$suite->addTestSuite('Orm_EntityManagerFactoryTest');
//$suite->addTestSuite('Orm_ConfigurableTestCase');
$suite->addTest(Orm_Component_AllTests::suite());
$suite->addTest(Orm_Query_AllTests::suite());
$suite->addTest(Orm_Hydration_AllTests::suite());
$suite->addTest(Orm_Entity_AllTests::suite());
$suite->addTest(Orm_Ticket_AllTests::suite());
return $suite;
......
......@@ -27,7 +27,7 @@
* @author Bjarte Stien Karlsen <doctrine@bjartek.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision: 3754 $
*/
require_once 'lib/DoctrineTestInit.php';
......
......@@ -29,12 +29,12 @@ class CustomAccessorMutatorTestEntity extends Doctrine_Entity
public function getUsernameCustom()
{
return $this->rawGetField('username') . "!";
return $this->_rawGetField('username') . "!";
}
public function setUsernameCustom($username)
{
$this->rawSetField('username', $username . "?");
$this->_rawSetField('username', $username . "?");
}
}
......@@ -47,11 +47,11 @@ class MagicAccessorMutatorTestEntity extends Doctrine_Entity
public function getUsername()
{
return $this->rawGetField('username') . "!";
return $this->_rawGetField('username') . "!";
}
public function setUsername($username)
{
$this->rawSetField('username', $username . "?");
$this->_rawSetField('username', $username . "?");
}
}
\ No newline at end of file
......@@ -8,14 +8,8 @@ require_once 'lib/DoctrineTestInit.php';
*/
class Orm_EntityManagerFactoryTest extends Doctrine_OrmTestCase
{
private $_emf;
private $_mockOptions = array('driver' => 'mock', 'user' => '', 'password' => '');
protected function setUp() {
parent::setUp();
$this->_emf = $this->sharedFixture['emf'];
}
protected function tearDown() {
parent::tearDown();
}
......
This diff is collapsed.
......@@ -29,7 +29,7 @@ require_once 'lib/DoctrineTestInit.php';
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
* @todo 1) [romanb] We might want to split the SQL generation tests into multiple
* testcases later since we'll have a lot of them and we might want to have special SQL
......@@ -40,7 +40,7 @@ class Orm_Query_DeleteSqlGenerationTest extends Doctrine_OrmTestCase
public function assertSqlGeneration($dqlToBeTested, $sqlToBeConfirmed)
{
try {
$entityManager = $this->sharedFixture['em'];
$entityManager = $this->_em;
$query = $entityManager->createQuery($dqlToBeTested);
parent::assertEquals($sqlToBeConfirmed, $query->getSql());
......
......@@ -36,7 +36,7 @@ class Orm_Query_DqlGenerationTest extends Doctrine_OrmTestCase
{
protected function createQuery()
{
$entityManager = $this->sharedFixture['em'];
$entityManager = $this->_em;
return $entityManager->createQuery();
}
......
......@@ -31,7 +31,7 @@ require_once 'lib/DoctrineTestInit.php';
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Orm_Query_IdentifierRecognitionTest extends Doctrine_OrmTestCase
......@@ -39,7 +39,7 @@ class Orm_Query_IdentifierRecognitionTest extends Doctrine_OrmTestCase
public function testSingleAliasDeclarationIsSupported()
{
$entityManager = $this->sharedFixture['em'];
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u.* FROM CmsUser u');
$parserResult = $query->parse();
......@@ -54,7 +54,7 @@ class Orm_Query_IdentifierRecognitionTest extends Doctrine_OrmTestCase
public function testSingleAliasDeclarationWithIndexByIsSupported()
{
$entityManager = $this->sharedFixture['em'];
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u.* FROM CmsUser u INDEX BY id');
$parserResult = $query->parse();
......@@ -69,7 +69,7 @@ class Orm_Query_IdentifierRecognitionTest extends Doctrine_OrmTestCase
public function testQueryParserSupportsMultipleAliasDeclarations()
{
$entityManager = $this->sharedFixture['em'];
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u.* FROM CmsUser u INDEX BY id LEFT JOIN u.phonenumbers p');
$parserResult = $query->parse();
......@@ -93,7 +93,7 @@ class Orm_Query_IdentifierRecognitionTest extends Doctrine_OrmTestCase
public function testQueryParserSupportsMultipleAliasDeclarationsWithIndexBy()
{
$entityManager = $this->sharedFixture['em'];
$entityManager = $this->_em;
$query = $entityManager->createQuery('SELECT u.* FROM CmsUser u INDEX BY id LEFT JOIN u.articles a INNER JOIN u.phonenumbers pn INDEX BY phonenumber');
$parserResult = $query->parse();
......
This diff is collapsed.
......@@ -29,7 +29,7 @@ require_once 'lib/DoctrineTestInit.php';
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
* @todo 1) [romanb] We might want to split the SQL generation tests into multiple
* testcases later since we'll have a lot of them and we might want to have special SQL
......@@ -40,7 +40,7 @@ class Orm_Query_SelectSqlGenerationTest extends Doctrine_OrmTestCase
public function assertSqlGeneration($dqlToBeTested, $sqlToBeConfirmed)
{
try {
$entityManager = $this->sharedFixture['em'];
$entityManager = $this->_em;
$query = $entityManager->createQuery($dqlToBeTested);
//echo print_r($query->parse()->getQueryFields(), true) . "\n";
......
This diff is collapsed.
This diff is collapsed.
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