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.
This commit is contained in:
parent
7757de9622
commit
7206b1dd51
@ -29,6 +29,7 @@
|
||||
* @link www.phpdoctrine.org
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
* @todo Can this be removed?
|
||||
*/
|
||||
class Doctrine_Cache extends Doctrine_EventListener implements Countable, IteratorAggregate
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
*
|
||||
* @var Doctrine_Connection
|
||||
*/
|
||||
protected $_conn;
|
||||
protected $_em;
|
||||
|
||||
/**
|
||||
* The names of the parent classes (ancestors).
|
||||
@ -114,14 +114,6 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
*/
|
||||
protected $_generators = array();
|
||||
|
||||
/**
|
||||
* An array containing all filters attached to the class.
|
||||
*
|
||||
* @see Doctrine_Record_Filter
|
||||
* @var array $_filters
|
||||
*/
|
||||
protected $_filters = array();
|
||||
|
||||
/**
|
||||
* The mapped columns and their mapping definitions.
|
||||
* Keys are column names and values are mapping definitions.
|
||||
@ -157,6 +149,13 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
*/
|
||||
protected $_fieldNames = array();
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
protected $_attributes = array('loadReferences' => true);
|
||||
|
||||
/**
|
||||
* An array of column names. Keys are field names and values column names.
|
||||
* Used to look up column names from field names.
|
||||
@ -166,6 +165,13 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
*/
|
||||
protected $_columnNames = array();
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
protected $_subclassFieldNames = array();
|
||||
|
||||
/**
|
||||
* Caches enum value mappings. Keys are field names and values arrays with the
|
||||
* mapping.
|
||||
@ -278,7 +284,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
{
|
||||
$this->_entityName = $entityName;
|
||||
$this->_rootEntityName = $entityName;
|
||||
$this->_conn = $em;
|
||||
$this->_em = $em;
|
||||
$this->_parser = new Doctrine_Relation_Parser($this);
|
||||
}
|
||||
|
||||
@ -287,12 +293,12 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
*/
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->_conn;
|
||||
return $this->_em;
|
||||
}
|
||||
|
||||
public function getEntityManager()
|
||||
{
|
||||
return $this->_conn;
|
||||
return $this->_em;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -348,11 +354,11 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
*/
|
||||
public function isIdentifierComposite()
|
||||
{
|
||||
return ($this->_identifierType == Doctrine::IDENTIFIER_COMPOSITE);
|
||||
return $this->_identifierType == Doctrine::IDENTIFIER_COMPOSITE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the field is unique
|
||||
* Check if the field is unique.
|
||||
*
|
||||
* @param string $fieldName The field name
|
||||
* @return boolean TRUE if the field is unique, FALSE otherwise.
|
||||
@ -369,7 +375,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the field is not null
|
||||
* Check if the field is not null.
|
||||
*
|
||||
* @param string $fieldName The field name
|
||||
* @return boolean TRUE if the field is not null, FALSE otherwise.
|
||||
@ -391,6 +397,8 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
* adds an index to this table
|
||||
*
|
||||
* @return void
|
||||
* @deprecated
|
||||
* @todo Should be done through setTableOption().
|
||||
*/
|
||||
public function addIndex($index, array $definition)
|
||||
{
|
||||
@ -401,6 +409,8 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
* getIndex
|
||||
*
|
||||
* @return array|boolean array on success, FALSE on failure
|
||||
* @todo Should be done through getTableOption().
|
||||
* @deprecated
|
||||
*/
|
||||
public function getIndex($index)
|
||||
{
|
||||
@ -424,19 +434,6 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
*/
|
||||
public function setOption($name, $value)
|
||||
{
|
||||
/*switch ($name) {
|
||||
case 'tableName':
|
||||
case 'index':
|
||||
case 'sequenceName':
|
||||
case 'type':
|
||||
case 'charset':
|
||||
case 'collation':
|
||||
case 'collate':
|
||||
return $this->setTableOption($name, $value);
|
||||
case 'enumMap':
|
||||
$this->_enumMap = $value;
|
||||
return;
|
||||
}*/
|
||||
$this->_options[$name] = $value;
|
||||
}
|
||||
|
||||
@ -468,7 +465,6 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
return (isset($this->_invokedMethods[$method])) ?
|
||||
$this->_invokedMethods[$method] : false;
|
||||
}
|
||||
|
||||
public function addBehaviorMethod($method, $behavior)
|
||||
{
|
||||
$this->_invokedMethods[$method] = $class;
|
||||
@ -540,7 +536,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
public function getColumnMapping($columnName)
|
||||
{
|
||||
return isset($this->_mappedColumns[$columnName]) ?
|
||||
$this->_mappedColumns[$columnName] : false;
|
||||
$this->_mappedColumns[$columnName] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -555,11 +551,9 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
public function getFieldName($columnName)
|
||||
{
|
||||
return isset($this->_fieldNames[$columnName]) ?
|
||||
$this->_fieldNames[$columnName] : $columnName;
|
||||
$this->_fieldNames[$columnName] : $columnName;
|
||||
}
|
||||
|
||||
private $_subclassFieldNames = array();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -572,7 +566,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
}
|
||||
|
||||
$classMetadata = $this;
|
||||
$conn = $this->_conn;
|
||||
$conn = $this->_em;
|
||||
|
||||
foreach ($classMetadata->getSubclasses() as $subClass) {
|
||||
$subClassMetadata = $conn->getClassMetadata($subClass);
|
||||
@ -882,7 +876,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
}
|
||||
|
||||
$columnName = $this->getColumnName($fieldName);
|
||||
if ( ! $this->_conn->getAttribute(Doctrine::ATTR_USE_NATIVE_ENUM) &&
|
||||
if ( ! $this->_em->getAttribute(Doctrine::ATTR_USE_NATIVE_ENUM) &&
|
||||
isset($this->_mappedColumns[$columnName]['values'][$index])) {
|
||||
$enumValue = $this->_mappedColumns[$columnName]['values'][$index];
|
||||
} else {
|
||||
@ -904,7 +898,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
{
|
||||
$values = $this->getEnumValues($fieldName);
|
||||
$index = array_search($value, $values);
|
||||
if ($index === false || ! $this->_conn->getAttribute(Doctrine::ATTR_USE_NATIVE_ENUM)) {
|
||||
if ($index === false || ! $this->_em->getAttribute(Doctrine::ATTR_USE_NATIVE_ENUM)) {
|
||||
return $index;
|
||||
}
|
||||
|
||||
@ -1288,7 +1282,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
public function setInheritanceType($type, array $options = array())
|
||||
{
|
||||
if ($parentClassNames = $this->getParentClasses()) {
|
||||
if ($this->_conn->getClassMetadata($parentClassNames[0])->getInheritanceType() != $type) {
|
||||
if ($this->_em->getClassMetadata($parentClassNames[0])->getInheritanceType() != $type) {
|
||||
throw new Doctrine_ClassMetadata_Exception("All classes in an inheritance hierarchy"
|
||||
. " must share the same inheritance mapping type. Mixing is not allowed.");
|
||||
}
|
||||
@ -1388,7 +1382,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
$this->_conn->export->exportTable($this);
|
||||
$this->_em->export->exportTable($this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1409,13 +1403,13 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
if ($this->_inheritanceType == Doctrine::INHERITANCE_TYPE_SINGLE_TABLE) {
|
||||
$parents = $this->getParentClasses();
|
||||
if ($parents) {
|
||||
$rootClass = $this->_conn->getClassMetadata(array_pop($parents));
|
||||
$rootClass = $this->_em->getClassMetadata(array_pop($parents));
|
||||
} else {
|
||||
$rootClass = $this;
|
||||
}
|
||||
$subClasses = $rootClass->getSubclasses();
|
||||
foreach ($subClasses as $subClass) {
|
||||
$subClassMetadata = $this->_conn->getClassMetadata($subClass);
|
||||
$subClassMetadata = $this->_em->getClassMetadata($subClass);
|
||||
$allColumns = array_merge($allColumns, $subClassMetadata->getColumns());
|
||||
}
|
||||
} else if ($this->_inheritanceType == Doctrine::INHERITANCE_TYPE_JOINED) {
|
||||
@ -1454,7 +1448,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
break;
|
||||
case 'boolean':
|
||||
if (isset($definition['default'])) {
|
||||
$definition['default'] = $this->_conn->convertBooleans($definition['default']);
|
||||
$definition['default'] = $this->_em->convertBooleans($definition['default']);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1608,21 +1602,6 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
$this->addGenerator($generator, get_class($generator));
|
||||
}
|
||||
|
||||
/**
|
||||
* unshiftFilter
|
||||
*
|
||||
* @param object Doctrine_Record_Filter $filter
|
||||
* @return object $this
|
||||
* @todo Remove filters, if possible.
|
||||
*/
|
||||
public function unshiftFilter(Doctrine_Record_Filter $filter)
|
||||
{
|
||||
$filter->setTable($this);
|
||||
array_unshift($this->_filters, $filter);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* getTree
|
||||
*
|
||||
@ -1657,17 +1636,6 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
return ( ! is_null($this->getOption('treeImpl'))) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* getFilters
|
||||
*
|
||||
* @return array $filters
|
||||
* @todo Remove filters, if possible.
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return $this->_filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a persistent field is inherited from a superclass.
|
||||
*
|
||||
@ -1726,8 +1694,8 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
*/
|
||||
public function setTableName($tableName)
|
||||
{
|
||||
$this->setTableOption('tableName', $this->_conn->getConnection()
|
||||
->formatter->getTableName($tableName));
|
||||
$this->setTableOption('tableName', $this->_em->getConnection()
|
||||
->getFormatter()->getTableName($tableName));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1740,7 +1708,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
public function serialize()
|
||||
{
|
||||
//$contents = get_object_vars($this);
|
||||
/* @TODO How to handle $this->_conn and $this->_parser ? */
|
||||
/* @TODO How to handle $this->_em and $this->_parser ? */
|
||||
//return serialize($contents);
|
||||
return "";
|
||||
}
|
||||
@ -1834,6 +1802,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
* @param string $name optional constraint name
|
||||
* @return Doctrine_Entity this object
|
||||
* @todo Should be done through $_tableOptions
|
||||
* @deprecated
|
||||
*/
|
||||
public function check($constraint, $name = null)
|
||||
{
|
||||
@ -1847,7 +1816,6 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function _addCheckConstraint($definition, $name)
|
||||
{
|
||||
if (is_string($name)) {
|
||||
@ -1857,21 +1825,6 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a custom mapper for the entity class.
|
||||
*
|
||||
* @param string $mapperClassName The class name of the custom mapper.
|
||||
* @deprecated
|
||||
*/
|
||||
public function setCustomMapperClass($mapperClassName)
|
||||
{
|
||||
if ( ! is_subclass_of($mapperClassName, 'Doctrine_Mapper')) {
|
||||
throw new Doctrine_ClassMetadata_Exception("The custom mapper must be a subclass"
|
||||
. " of Doctrine_Mapper.");
|
||||
}
|
||||
$this->_customRepositoryClassName = $mapperClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a custom mapper for the entity class.
|
||||
*
|
||||
@ -1888,17 +1841,11 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the custom mapper class used for the entity class.
|
||||
* Gets the name of the custom repository class used for the entity class.
|
||||
*
|
||||
* @return string|null The name of the custom mapper class or NULL if the entity
|
||||
* class does not have a custom mapper class.
|
||||
* @deprecated
|
||||
* @return string|null The name of the custom repository class or NULL if the entity
|
||||
* class does not have a custom repository class.
|
||||
*/
|
||||
public function getCustomMapperClass()
|
||||
{
|
||||
return $this->_customRepositoryClassName;
|
||||
}
|
||||
|
||||
public function getCustomRepositoryClass()
|
||||
{
|
||||
return $this->_customRepositoryClassName;
|
||||
@ -1909,12 +1856,13 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
*/
|
||||
public function setEntityType($type)
|
||||
{
|
||||
//Doctrine::CLASSTYPE_ENTITY
|
||||
//Doctrine::CLASSTYPE_MAPPED_SUPERCLASS
|
||||
//Doctrine::CLASSTYPE_TRANSIENT
|
||||
//Entity::TYPE_ENTITY
|
||||
//Entity::TYPE_MAPPED_SUPERCLASS
|
||||
//Entity::TYPE_TRANSIENT
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds the entity instance of this class to a specific EntityManager.
|
||||
*
|
||||
* @todo Implementation. Replaces the bindComponent() methods on the old Doctrine_Manager.
|
||||
* Binding an Entity to a specific EntityManager in 2.0 is the same as binding
|
||||
@ -1974,17 +1922,21 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
|
||||
|
||||
public function hasAttribute($name)
|
||||
{
|
||||
return false;
|
||||
return isset($this->_attributes[$name]);
|
||||
}
|
||||
|
||||
public function getAttribute($name)
|
||||
{
|
||||
return null;
|
||||
if ($this->hasAttribute($name)) {
|
||||
return $this->_attributes[$name];
|
||||
}
|
||||
}
|
||||
|
||||
public function setAttribute($name, $value)
|
||||
{
|
||||
;
|
||||
if ($this->hasAttribute($name)) {
|
||||
$this->_attributes[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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)
|
||||
public function delete($clearColl = false)
|
||||
{
|
||||
if ($conn == null) {
|
||||
$conn = $this->_mapper->getConnection();
|
||||
}
|
||||
$conn = $this->_mapper->getConnection();
|
||||
|
||||
try {
|
||||
$conn->beginInternalTransaction();
|
||||
@ -920,8 +913,9 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
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
|
||||
|
@ -1,4 +1,23 @@
|
||||
<?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
|
||||
* Creates the database for the connection instance.
|
||||
*
|
||||
* Method for creating 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)
|
||||
|
||||
public function getFormatter()
|
||||
{
|
||||
if ($attribute >= 100) {
|
||||
parent::setAttribute($attribute, $value);
|
||||
} else {
|
||||
if ($this->isConnected) {
|
||||
$this->dbh->setAttribute($attribute, $value);
|
||||
} else {
|
||||
$this->pendingAttributes[$attribute] = $value;
|
||||
}
|
||||
if ( ! $this->modules['formatter']) {
|
||||
$this->modules['formatter'] = new Doctrine_Formatter($this);
|
||||
}
|
||||
return $this;
|
||||
return $this->modules['formatter'];
|
||||
}
|
||||
|
||||
public function hasAttribute($name)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->modules[$name];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
*
|
||||
@ -102,6 +102,9 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection
|
||||
*/
|
||||
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);
|
||||
|
@ -36,7 +36,9 @@
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@
|
||||
* <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);
|
||||
}
|
||||
|
@ -55,15 +55,6 @@
|
||||
*/
|
||||
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]);
|
||||
|
@ -1,9 +1,39 @@
|
||||
<?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,11 +54,24 @@ 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
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -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
|
||||
|
@ -1,4 +1,23 @@
|
||||
<?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
|
||||
@ -102,4 +102,60 @@ class Doctrine_Query_Production_Subselect extends Doctrine_Query_Production
|
||||
. (($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;
|
||||
}
|
||||
|
||||
|
@ -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$
|
||||
*/
|
||||
abstract class Doctrine_Query_SqlBuilder
|
||||
@ -82,4 +82,199 @@ abstract class Doctrine_Query_SqlBuilder
|
||||
|
||||
|
||||
// End of Common SQL generations
|
||||
|
||||
|
||||
|
||||
/** The following is just test/draft code for now. */
|
||||
|
||||
/*private $_sql;
|
||||
private $_conditionalTerms = array();
|
||||
private $_conditionalFactors = array();
|
||||
private $_conditionalPrimaries = array();
|
||||
private $_variableDeclaration = array();
|
||||
private $_expressions = array();
|
||||
private $_deleteClause;
|
||||
private $_whereClause;
|
||||
|
||||
public function visitVariableDeclaration($variableDeclaration)
|
||||
{
|
||||
echo " VariableDeclaration ";
|
||||
// Basic handy variables
|
||||
$parserResult = $variableDeclaration->getParser()->getParserResult();
|
||||
$queryComponent = $parserResult->getQueryComponent($variableDeclaration->getComponentAlias());
|
||||
|
||||
// Retrieving connection
|
||||
$manager = Doctrine_EntityManagerFactory::getManager();
|
||||
$conn = $manager->getConnection();
|
||||
|
||||
$this->_variableDeclaration[] = $conn->quoteIdentifier($queryComponent['metadata']->getTableName()) . ' '
|
||||
. $conn->quoteIdentifier($parserResult->getTableAliasFromComponentAlias(
|
||||
$variableDeclaration->getComponentAlias()));
|
||||
}
|
||||
|
||||
public function visitDeleteClause($deleteClause)
|
||||
{
|
||||
echo " DeleteClause ";
|
||||
$this->_deleteClause = 'DELETE FROM ' . array_pop($this->_variableDeclaration);
|
||||
}
|
||||
|
||||
public function visitDeleteStatement($deleteStatement)
|
||||
{
|
||||
echo " DeleteStatement ";
|
||||
$this->_sql = $this->_deleteClause;
|
||||
if ($this->_whereClause) {
|
||||
$this->_sql .= $this->_whereClause;
|
||||
} else {
|
||||
$this->_sql .= " WHERE 1 = 1";
|
||||
}
|
||||
}
|
||||
|
||||
public function visitWhereClause($whereClause)
|
||||
{
|
||||
echo " WhereClause ";
|
||||
if ($this->_expressions) {
|
||||
$this->_whereClause = ' WHERE ' . array_pop($this->_expressions);
|
||||
}
|
||||
}
|
||||
|
||||
public function visitConditionalExpression($conditionalExpression)
|
||||
{
|
||||
echo " ConditionalExpression ";
|
||||
$count = count($conditionalExpression->getConditionalTerms());
|
||||
$terms = array();
|
||||
for ($i=0; $i<$count; $i++) {
|
||||
$terms[] = array_pop($this->_conditionalTerms);
|
||||
}
|
||||
|
||||
$this->_expressions[] = implode(' OR ', $terms);
|
||||
}
|
||||
|
||||
public function visitSimpleConditionalExpression($simpleConditionalExpression)
|
||||
{
|
||||
//var_dump($this->_expressions);
|
||||
echo " SimpleConditionalExpression ";
|
||||
$rightExpr = array_pop($this->_expressions);
|
||||
$leftExpr = array_pop($this->_expressions);
|
||||
$this->_expressions[] = $leftExpr . ' ' . $rightExpr;
|
||||
}
|
||||
|
||||
public function visitConditionalPrimary($conditionalPrimary)
|
||||
{
|
||||
echo " ConditionalPrimary ";
|
||||
if ($this->_expressions) {
|
||||
$this->_conditionalPrimaries[] = '(' . array_pop($this->_expressions) . ')';
|
||||
}
|
||||
}
|
||||
|
||||
public function visitConditionalTerm($conditionalTerm)
|
||||
{
|
||||
echo " ConditionalTerm ";
|
||||
$count = count($conditionalTerm->getConditionalFactors());
|
||||
$factors = array();
|
||||
for ($i=0; $i<$count; $i++) {
|
||||
$factors[] = array_pop($this->_conditionalFactors);
|
||||
}
|
||||
|
||||
$this->_conditionalTerms[] = implode(' AND ', $factors);
|
||||
}
|
||||
|
||||
public function visitConditionalFactor($conditionalFactor)
|
||||
{
|
||||
echo " ConditionalFactor ";
|
||||
if ($this->_conditionalPrimaries) {
|
||||
$this->_conditionalFactors[] = 'NOT ' . array_pop($this->_conditionalPrimaries);
|
||||
}
|
||||
}
|
||||
|
||||
public function visitBetweenExpression($betweenExpression)
|
||||
{
|
||||
$this->_expressions[] = (($betweenExpression->getNot()) ? 'NOT ' : '') . 'BETWEEN '
|
||||
. array_pop($this->_expressions) . ' AND ' . array_pop($this->_expressions);
|
||||
}
|
||||
|
||||
public function visitLikeExpression($likeExpression)
|
||||
{
|
||||
$this->_expressions[] = (($likeExpression->getNot()) ? 'NOT ' : '') . 'LIKE ' .
|
||||
array_pop($this->_expressions)
|
||||
. (($likeExpression->getEscapeString() !== null) ? ' ESCAPE ' . $likeExpression->getEscapeString() : '');
|
||||
}
|
||||
|
||||
public function visitInExpression($inExpression)
|
||||
{
|
||||
$count = count($inExpression->getAtoms());
|
||||
$atoms = array();
|
||||
for ($i=0; $i<$count; $i++) {
|
||||
$atoms[] = array_pop($this->_expressions);
|
||||
}
|
||||
|
||||
$this->_expressions[] = (($inExpression->getNot()) ? 'NOT ' : '') . 'IN ('
|
||||
. (($inExpression->getSubselect() !== null) ? array_pop($this->_expressions) :
|
||||
implode(', ', $atoms))
|
||||
. ')';
|
||||
}
|
||||
|
||||
public function visitNullComparisonExpression($nullComparisonExpression)
|
||||
{
|
||||
$this->_expressions[] = 'IS ' . (($nullComparisonExpression->getNot()) ? 'NOT ' : '') . 'NULL';
|
||||
}
|
||||
|
||||
public function visitAtom($atom)
|
||||
{
|
||||
$conn = $atom->getParser()->getSqlBuilder()->getConnection();
|
||||
switch ($atom->getType()) {
|
||||
case 'param':
|
||||
$this->_expressions[] = $atom->getValue();
|
||||
break;
|
||||
case 'integer':
|
||||
case 'float':
|
||||
$this->_expressions[] = $conn->quote($atom->getValue(), $atom->getType());
|
||||
break;
|
||||
default:
|
||||
$stringQuoting = $this->_conn->getProperty('string_quoting');
|
||||
$this->_expressions[] = $stringQuoting['start']
|
||||
. $conn->quote($this->_value, $this->_type)
|
||||
. $stringQuoting['end'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function visitPathExpression($pathExpression)
|
||||
{
|
||||
echo " PathExpression ";
|
||||
// Basic handy variables
|
||||
$parserResult = $pathExpression->getParser()->getParserResult();
|
||||
|
||||
// Retrieving connection
|
||||
$manager = Doctrine_EntityManagerFactory::getManager();
|
||||
$conn = $manager->getConnection();
|
||||
|
||||
// Looking for queryComponent to fetch
|
||||
$queryComponent = $parserResult->getQueryComponent($pathExpression->getComponentAlias());
|
||||
|
||||
// Generating the SQL piece
|
||||
$str = $parserResult->getTableAliasFromComponentAlias($pathExpression->getComponentAlias()) . '.'
|
||||
. $queryComponent['metadata']->getColumnName($pathExpression->getFieldName());
|
||||
|
||||
$this->_expressions[] = $conn->quoteIdentifier($str);
|
||||
}
|
||||
|
||||
public function visitComparisonExpression($comparisonExpression)
|
||||
{
|
||||
echo " ComparisonExpression ";
|
||||
|
||||
$expr = $comparisonExpression->getOperator() . ' ';
|
||||
if ($comparisonExpression->getIsSubselect()) {
|
||||
$expr .= '(' . array_pop($this->_expressions) . ')';
|
||||
} else {
|
||||
$expr .= array_pop($this->_expressions);
|
||||
}
|
||||
$this->_expressions[] = $expr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getSql()
|
||||
{
|
||||
return $this->_sql;
|
||||
}*/
|
||||
}
|
||||
|
@ -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 . "?");
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
@ -45,8 +45,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
// Faked query components
|
||||
$queryComponents = array(
|
||||
'u' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsUser'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsUser'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsUser'),
|
||||
'parent' => null,
|
||||
'relation' => null,
|
||||
'map' => null
|
||||
@ -115,16 +114,14 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
// Faked query components
|
||||
$queryComponents = array(
|
||||
'u' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsUser'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsUser'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsUser'),
|
||||
'parent' => null,
|
||||
'relation' => null,
|
||||
'map' => null,
|
||||
'agg' => array('0' => 'nameUpper')
|
||||
),
|
||||
'p' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsPhonenumber'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsPhonenumber'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsPhonenumber'),
|
||||
'parent' => 'u',
|
||||
'relation' => $this->_em->getClassMetadata('CmsUser')->getRelation('phonenumbers'),
|
||||
'map' => null
|
||||
@ -198,7 +195,6 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
} else if ($hydrationMode == Doctrine::HYDRATE_SCALAR) {
|
||||
$this->assertTrue(is_array($result));
|
||||
$this->assertEquals(3, count($result));
|
||||
|
||||
$this->assertEquals(1, $result[0]['u_id']);
|
||||
$this->assertEquals('developer', $result[0]['u_status']);
|
||||
$this->assertEquals('ROMANB', $result[0]['u_nameUpper']);
|
||||
@ -222,15 +218,13 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
// Faked query components
|
||||
$queryComponents = array(
|
||||
'u' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsUser'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsUser'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsUser'),
|
||||
'parent' => null,
|
||||
'relation' => null,
|
||||
'map' => null
|
||||
),
|
||||
'p' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsPhonenumber'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsPhonenumber'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsPhonenumber'),
|
||||
'parent' => 'u',
|
||||
'relation' => $this->_em->getClassMetadata('CmsUser')->getRelation('phonenumbers'),
|
||||
'map' => null,
|
||||
@ -308,16 +302,14 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
// Faked query components
|
||||
$queryComponents = array(
|
||||
'u' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsUser'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsUser'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsUser'),
|
||||
'parent' => null,
|
||||
'relation' => null,
|
||||
'agg' => array('0' => 'nameUpper'),
|
||||
'map' => 'id'
|
||||
),
|
||||
'p' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsPhonenumber'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsPhonenumber'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsPhonenumber'),
|
||||
'parent' => 'u',
|
||||
'relation' => $this->_em->getClassMetadata('CmsUser')->getRelation('phonenumbers'),
|
||||
'map' => 'phonenumber'
|
||||
@ -414,23 +406,20 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
// Faked query components
|
||||
$queryComponents = array(
|
||||
'u' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsUser'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsUser'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsUser'),
|
||||
'parent' => null,
|
||||
'relation' => null,
|
||||
'map' => null,
|
||||
'agg' => array('0' => 'nameUpper')
|
||||
),
|
||||
'p' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsPhonenumber'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsPhonenumber'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsPhonenumber'),
|
||||
'parent' => 'u',
|
||||
'relation' => $this->_em->getClassMetadata('CmsUser')->getRelation('phonenumbers'),
|
||||
'map' => null
|
||||
),
|
||||
'a' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsArticle'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsArticle'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsArticle'),
|
||||
'parent' => 'u',
|
||||
'relation' => $this->_em->getClassMetadata('CmsUser')->getRelation('articles'),
|
||||
'map' => null
|
||||
@ -573,30 +562,26 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
// Faked query components
|
||||
$queryComponents = array(
|
||||
'u' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsUser'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsUser'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsUser'),
|
||||
'parent' => null,
|
||||
'relation' => null,
|
||||
'map' => null,
|
||||
'agg' => array('0' => 'nameUpper')
|
||||
),
|
||||
'p' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsPhonenumber'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsPhonenumber'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsPhonenumber'),
|
||||
'parent' => 'u',
|
||||
'relation' => $this->_em->getClassMetadata('CmsUser')->getRelation('phonenumbers'),
|
||||
'map' => null
|
||||
),
|
||||
'a' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsArticle'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsArticle'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsArticle'),
|
||||
'parent' => 'u',
|
||||
'relation' => $this->_em->getClassMetadata('CmsUser')->getRelation('articles'),
|
||||
'map' => null
|
||||
),
|
||||
'c' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsComment'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsComment'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsComment'),
|
||||
'parent' => 'a',
|
||||
'relation' => $this->_em->getClassMetadata('CmsArticle')->getRelation('comments'),
|
||||
'map' => null
|
||||
@ -713,9 +698,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
$this->assertEquals('First!', $result[0][0]['articles'][0]['comments'][0]['topic']);
|
||||
|
||||
$this->assertTrue(isset($result[0][0]['articles'][0]['comments']));
|
||||
$this->assertFalse(isset($result[0][0]['articles'][1]['comments']));
|
||||
$this->assertFalse(isset($result[1][0]['articles'][0]['comments']));
|
||||
$this->assertFalse(isset($result[1][0]['articles'][1]['comments']));
|
||||
// empty collections/arrays
|
||||
$this->assertTrue(isset($result[0][0]['articles'][1]['comments']));
|
||||
$this->assertTrue(isset($result[1][0]['articles'][0]['comments']));
|
||||
$this->assertTrue(isset($result[1][0]['articles'][1]['comments']));
|
||||
}
|
||||
|
||||
if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
|
||||
@ -736,8 +722,25 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
// article comments
|
||||
$this->assertTrue($result[0][0]['articles'][0]['comments'] instanceof Doctrine_Collection);
|
||||
$this->assertTrue($result[0][0]['articles'][0]['comments'][0] instanceof Doctrine_Entity);
|
||||
// empty comment collections
|
||||
$this->assertTrue($result[0][0]['articles'][1]['comments'] instanceof Doctrine_Collection);
|
||||
$this->assertEquals(0, count($result[0][0]['articles'][1]['comments']));
|
||||
$this->assertTrue($result[1][0]['articles'][0]['comments'] instanceof Doctrine_Collection);
|
||||
$this->assertEquals(0, count($result[1][0]['articles'][0]['comments']));
|
||||
$this->assertTrue($result[1][0]['articles'][1]['comments'] instanceof Doctrine_Collection);
|
||||
$this->assertEquals(0, count($result[1][0]['articles'][1]['comments']));
|
||||
} else if ($hydrationMode == Doctrine::HYDRATE_SCALAR) {
|
||||
//...
|
||||
} else if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
|
||||
//...
|
||||
|
||||
// empty comment collections
|
||||
$this->assertTrue(is_array($result[0][0]['articles'][1]['comments']));
|
||||
$this->assertEquals(0, count($result[0][0]['articles'][1]['comments']));
|
||||
$this->assertTrue(is_array($result[1][0]['articles'][0]['comments']));
|
||||
$this->assertEquals(0, count($result[1][0]['articles'][0]['comments']));
|
||||
$this->assertTrue(is_array($result[1][0]['articles'][1]['comments']));
|
||||
$this->assertEquals(0, count($result[1][0]['articles'][1]['comments']));
|
||||
}
|
||||
}
|
||||
|
||||
@ -768,15 +771,13 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
// Faked query components
|
||||
$queryComponents = array(
|
||||
'c' => array(
|
||||
'table' => $this->_em->getClassMetadata('ForumCategory'),
|
||||
'mapper' => $this->_em->getEntityPersister('ForumCategory'),
|
||||
'metadata' => $this->_em->getClassMetadata('ForumCategory'),
|
||||
'parent' => null,
|
||||
'relation' => null,
|
||||
'map' => null
|
||||
),
|
||||
'b' => array(
|
||||
'table' => $this->_em->getClassMetadata('ForumBoard'),
|
||||
'mapper' => $this->_em->getEntityPersister('ForumBoard'),
|
||||
'metadata' => $this->_em->getClassMetadata('ForumBoard'),
|
||||
'parent' => 'c',
|
||||
'relation' => $this->_em->getClassMetadata('ForumCategory')->getRelation('boards'),
|
||||
'map' => null
|
||||
@ -904,8 +905,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
|
||||
// Faked query components
|
||||
$queryComponents = array(
|
||||
'u' => array(
|
||||
'table' => $this->_em->getClassMetadata('CmsUser'),
|
||||
'mapper' => $this->_em->getEntityPersister('CmsUser'),
|
||||
'metadata' => $this->_em->getClassMetadata('CmsUser'),
|
||||
'parent' => null,
|
||||
'relation' => null,
|
||||
'map' => null
|
||||
|
@ -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();
|
||||
|
||||
|
@ -30,7 +30,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
|
||||
@ -41,7 +41,7 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
|
||||
public function assertValidDql($dql)
|
||||
{
|
||||
try {
|
||||
$entityManager = $this->sharedFixture['em'];
|
||||
$entityManager = $this->_em;
|
||||
$query = $entityManager->createQuery($dql);
|
||||
$parserResult = $query->parse();
|
||||
} catch (Doctrine_Exception $e) {
|
||||
@ -52,7 +52,7 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase
|
||||
public function assertInvalidDql($dql)
|
||||
{
|
||||
try {
|
||||
$entityManager = $this->sharedFixture['em'];
|
||||
$entityManager = $this->_em;
|
||||
$query = $entityManager->createQuery($dql);
|
||||
$query->setDql($dql);
|
||||
$parserResult = $query->parse();
|
||||
|
@ -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";
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
* @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_UpdateSqlGenerationTest 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());
|
||||
|
@ -1,59 +0,0 @@
|
||||
<?php
|
||||
require_once 'lib/DoctrineTestInit.php';
|
||||
|
||||
class Orm_UnitOfWorkTestCase extends Doctrine_OrmTestCase
|
||||
{
|
||||
private $_unitOfWork;
|
||||
private $_user;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$em = new Doctrine_EntityManager(new Doctrine_Connection_Mock());
|
||||
$this->_user = new ForumUser();
|
||||
$this->_unitOfWork = $em->getUnitOfWork();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
$this->_user->free();
|
||||
}
|
||||
|
||||
public function testRegisterNew()
|
||||
{
|
||||
$this->_user->username = 'romanb';
|
||||
$this->_user->id = 1;
|
||||
$this->_unitOfWork->registerNew($this->_user);
|
||||
$this->assertFalse($this->_unitOfWork->contains($this->_user));
|
||||
$this->assertTrue($this->_unitOfWork->isRegisteredNew($this->_user));
|
||||
$this->assertFalse($this->_unitOfWork->isRegisteredDirty($this->_user));
|
||||
$this->assertFalse($this->_unitOfWork->isRegisteredRemoved($this->_user));
|
||||
}
|
||||
|
||||
public function testRegisterDirty()
|
||||
{
|
||||
$this->_user->username = 'romanb';
|
||||
$this->_user->id = 1;
|
||||
$this->assertEquals(Doctrine_Entity::STATE_TDIRTY, $this->_user->state());
|
||||
$this->assertFalse($this->_unitOfWork->contains($this->_user));
|
||||
$this->_unitOfWork->registerDirty($this->_user);
|
||||
$this->assertTrue($this->_unitOfWork->isRegisteredDirty($this->_user));
|
||||
$this->assertFalse($this->_unitOfWork->isRegisteredNew($this->_user));
|
||||
$this->assertFalse($this->_unitOfWork->isRegisteredRemoved($this->_user));
|
||||
}
|
||||
|
||||
public function testRegisterRemovedOnTransientEntityIsIgnored()
|
||||
{
|
||||
$this->_user->username = 'romanb';
|
||||
$this->_user->id = 1;
|
||||
$this->assertFalse($this->_unitOfWork->isRegisteredRemoved($this->_user));
|
||||
$this->_unitOfWork->registerRemoved($this->_user);
|
||||
$this->assertFalse($this->_unitOfWork->isRegisteredRemoved($this->_user));
|
||||
}
|
||||
|
||||
/*public function testSavedEntityHasIdentityAndIsManaged()
|
||||
{
|
||||
$this->_user->username = 'romanb';
|
||||
$this->_user->save();
|
||||
$this->assertTrue($this->_unitOfWork->hasIdentity($this->_user));
|
||||
$this->assertTrue($this->_unitOfWork->isManaged($this->_user));
|
||||
}*/
|
||||
}
|
@ -4,6 +4,8 @@
|
||||
*/
|
||||
class Doctrine_DbalTestCase extends Doctrine_TestCase
|
||||
{
|
||||
protected $_conn;
|
||||
|
||||
/**
|
||||
* setUp()
|
||||
*
|
||||
@ -16,8 +18,11 @@ class Doctrine_DbalTestCase extends Doctrine_TestCase
|
||||
{
|
||||
// Setup a db connection if there is none, yet. This makes it possible
|
||||
// to run tests that use a connection standalone.
|
||||
if ( ! isset($this->sharedFixture['connection'])) {
|
||||
$this->sharedFixture['connection'] = Doctrine_TestUtil::getConnection();
|
||||
if (isset($this->sharedFixture['conn'])) {
|
||||
$this->_conn = $this->sharedFixture['conn'];
|
||||
} else {
|
||||
$this->sharedFixture['conn'] = Doctrine_TestUtil::getConnection();
|
||||
$this->_conn = $this->sharedFixture['conn'];
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ class Doctrine_DbalTestSuite extends Doctrine_TestSuite
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->sharedFixture['connection'] = Doctrine_TestUtil::getConnection();
|
||||
$this->sharedFixture['conn'] = Doctrine_TestUtil::getConnection();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
|
@ -6,8 +6,24 @@
|
||||
class Doctrine_OrmTestCase extends Doctrine_TestCase
|
||||
{
|
||||
protected $_em;
|
||||
protected $_emf;
|
||||
|
||||
protected function setUp() {
|
||||
$this->_em = new Doctrine_EntityManager(new Doctrine_Connection_Mock());
|
||||
if (isset($this->sharedFixture['emf'], $this->sharedFixture['em'])) {
|
||||
$this->_emf = $this->sharedFixture['emf'];
|
||||
$this->_em = $this->sharedFixture['em'];
|
||||
} else {
|
||||
$emf = new Doctrine_EntityManagerFactory();
|
||||
$emf->setConfiguration(new Doctrine_Configuration());
|
||||
$emf->setEventManager(new Doctrine_EventManager());
|
||||
$connectionOptions = array(
|
||||
'driver' => 'mock',
|
||||
'user' => 'john',
|
||||
'password' => 'wayne'
|
||||
);
|
||||
$em = $emf->createEntityManager($connectionOptions, 'mockEM');
|
||||
$this->_emf = $emf;
|
||||
$this->_em = $em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,28 @@ class Doctrine_TestUtil
|
||||
{
|
||||
public static function getConnection()
|
||||
{
|
||||
$connFactory = new Doctrine_ConnectionFactory();
|
||||
|
||||
if (isset($GLOBALS['db_type'], $GLOBALS['db_username'], $GLOBALS['db_password'],
|
||||
$GLOBALS['db_host'], $GLOBALS['db_name'])) {
|
||||
$dsn = "{$GLOBALS['db_type']}://{$GLOBALS['db_username']}:{$GLOBALS['db_password']}@{$GLOBALS['db_host']}/{$GLOBALS['db_name']}";
|
||||
return Doctrine_Manager::connection($dsn, 'testconn');
|
||||
$params = array(
|
||||
'driver' => $GLOBALS['db_type'],
|
||||
'user' => $GLOBALS['db_username'],
|
||||
'password' => $GLOBALS['db_password'],
|
||||
'host' => $GLOBALS['db_host'],
|
||||
'database' => $GLOBALS['db_name']
|
||||
);
|
||||
//$dsn = "{$GLOBALS['db_type']}://{$GLOBALS['db_username']}:{$GLOBALS['db_password']}@{$GLOBALS['db_host']}/{$GLOBALS['db_name']}";
|
||||
//return Doctrine_Manager::connection($dsn, 'testconn');
|
||||
} else {
|
||||
return Doctrine_Manager::connection(new PDO('sqlite::memory:'), 'testconn');
|
||||
$params = array(
|
||||
'pdo' => new PDO('sqlite::memory:')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $connFactory->createConnection($params);
|
||||
}
|
||||
/*
|
||||
public static function autoloadModel($className)
|
||||
{
|
||||
$modelDir = dirname(__CLASS__) . '/../models/';
|
||||
@ -20,5 +33,5 @@ class Doctrine_TestUtil
|
||||
if (file_exists($fileName)) {
|
||||
require $fileName;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user