Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
580f21c4
Commit
580f21c4
authored
Sep 13, 2008
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more cleanups. introducing ClassLoader.
parent
76abfb84
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
181 additions
and
1051 deletions
+181
-1051
Doctrine.php
lib/Doctrine.php
+2
-1
ClassLoader.php
lib/Doctrine/Common/ClassLoader.php
+91
-0
Type.php
lib/Doctrine/DBAL/Types/Type.php
+2
-1
Expression.php
lib/Doctrine/Expression.php
+0
-147
Manager.php
lib/Doctrine/Manager.php
+0
-837
AbstractHydrator.php
lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
+1
-1
StandardHydrator.php
lib/Doctrine/ORM/Internal/Hydration/StandardHydrator.php
+6
-6
Query.php
lib/Doctrine/Query.php
+25
-1
ParserRule.php
lib/Doctrine/Query/ParserRule.php
+2
-1
BasicHydrationTest.php
tests/Orm/Hydration/BasicHydrationTest.php
+34
-34
DoctrineTestInit.php
tests/lib/DoctrineTestInit.php
+18
-22
No files found.
lib/Doctrine.php
View file @
580f21c4
...
@@ -31,7 +31,8 @@
...
@@ -31,7 +31,8 @@
* @since 1.0
* @since 1.0
* @version $Revision$
* @version $Revision$
* @todo Remove all the constants, attributes to the new attribute system,
* @todo Remove all the constants, attributes to the new attribute system,
* All methods to separate classes.
* All methods to appropriate classes.
* Finally remove this class.
*/
*/
final
class
Doctrine
final
class
Doctrine
{
{
...
...
lib/Doctrine/Common/ClassLoader.php
0 → 100644
View file @
580f21c4
<?php
/**
* A class loader used to load class files on demand.
*
* Usage recommendation:
* 1) Use only 1 class loader instance.
* 2) Prepend the base paths to your class libraries (including Doctrine's) to your include path.
* 3) DO NOT setCheckFileExists(true). Doing so is expensive.
*
* @since 2.0
*/
class
Doctrine_Common_ClassLoader
{
private
$_namespaceSeparator
=
'_'
;
private
$_fileExtension
=
'.php'
;
private
$_checkFileExists
=
false
;
private
$_basePath
;
public
function
__construct
()
{
}
public
function
setCheckFileExists
(
$bool
)
{
$this
->
_checkFileExists
=
$bool
;
}
public
function
setClassFileExtension
(
$extension
)
{
$this
->
_fileExtension
=
$extension
;
}
public
function
setNamespaceSeparator
(
$separator
)
{
$this
->
_namespaceSeparator
=
$separator
;
}
/**
* Sets a static base path that is prepended to the path derived from the class itself.
*
* @param string $basePath
*/
public
function
setBasePath
(
$basePath
)
{
$this
->
_basePath
=
$basePath
;
}
/**
* Loads the given class or interface.
*
* @param string $classname The name of the class to load.
* @return boolean TRUE if the class has been successfully loaded, FALSE otherwise.
*/
public
function
loadClass
(
$className
)
{
if
(
class_exists
(
$className
,
false
)
||
interface_exists
(
$className
,
false
))
{
return
false
;
}
$class
=
''
;
if
(
$this
->
_basePath
)
{
$class
.=
$this
->
_basePath
.
DIRECTORY_SEPARATOR
;
}
$class
.=
str_replace
(
$this
->
_namespaceSeparator
,
DIRECTORY_SEPARATOR
,
$className
)
.
$this
->
_fileExtension
;
if
(
$this
->
_checkFileExists
)
{
if
(
!
$fh
=
@
fopen
(
$class
,
'r'
,
true
))
{
return
false
;
}
@
fclose
(
$fh
);
}
require
$class
;
return
true
;
}
/**
* Registers this class loader using spl_autoload_register().
*/
public
function
register
()
{
spl_autoload_register
(
array
(
$this
,
'loadClass'
));
}
}
?>
\ No newline at end of file
lib/Doctrine/DBAL/Types/Type.php
View file @
580f21c4
...
@@ -29,7 +29,8 @@ abstract class Doctrine_DBAL_Types_Type
...
@@ -29,7 +29,8 @@ abstract class Doctrine_DBAL_Types_Type
abstract
public
function
getName
();
abstract
public
function
getName
();
/**
/**
* Factory method.
* Factory method to create type instances.
* Type instances are implemented as flyweights.
*
*
* @param string $name The name of the type (as returned by getName()).
* @param string $name The name of the type (as returned by getName()).
* @return Doctrine::DBAL::Types::Type
* @return Doctrine::DBAL::Types::Type
...
...
lib/Doctrine/Expression.php
deleted
100644 → 0
View file @
76abfb84
<?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::Expressions;
/**
* Doctrine_Expression
*
* @package Doctrine
* @subpackage Expression
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Merge all Expression classes into the appropriate DBAL DatabasePlatform classes.
*/
class
Doctrine_Expression
{
protected
$_expression
;
protected
$_conn
;
protected
$_tokenizer
;
/**
* Create an expression
*
* @param string $expr The expression
* @param Doctrine_Connection $conn The connection (optional)
* @return void
*/
public
function
__construct
(
$expr
,
$conn
=
null
)
{
$this
->
_tokenizer
=
new
Doctrine_Query_Tokenizer
();
$this
->
setExpression
(
$expr
);
if
(
$conn
!==
null
)
{
$this
->
_conn
=
$conn
;
}
}
/**
* getConnection
*
* @return Doctrine_Connection The connection
*/
public
function
getConnection
()
{
if
(
!
isset
(
$this
->
_conn
))
{
return
Doctrine_Manager
::
connection
();
}
return
$this
->
_conn
;
}
/**
* setExpression
*
* @param string $clause The expression to set
* @return void
*/
public
function
setExpression
(
$clause
)
{
$this
->
_expression
=
$this
->
parseClause
(
$clause
);
}
/**
* parseExpression
*
* @todo: What does this function do?
*
* @param string $expr The expression to parse
* @return void
*/
public
function
parseExpression
(
$expr
)
{
$pos
=
strpos
(
$expr
,
'('
);
if
(
$pos
===
false
)
{
return
$expr
;
}
// get the name of the function
$name
=
substr
(
$expr
,
0
,
$pos
);
$argStr
=
substr
(
$expr
,
(
$pos
+
1
),
-
1
);
// parse args
foreach
(
$this
->
_tokenizer
->
bracketExplode
(
$argStr
,
','
)
as
$arg
)
{
$args
[]
=
$this
->
parseClause
(
$arg
);
}
return
call_user_func_array
(
array
(
$this
->
getConnection
()
->
expression
,
$name
),
$args
);
}
/**
* parseClause
*
* @param string $clause The clause
* @return string The parse clause
*/
public
function
parseClause
(
$clause
)
{
$e
=
$this
->
_tokenizer
->
bracketExplode
(
$clause
,
' '
);
foreach
(
$e
as
$k
=>
$expr
)
{
$e
[
$k
]
=
$this
->
parseExpression
(
$expr
);
}
return
implode
(
' '
,
$e
);
}
/**
* getSql
*
* @return string The expression
*/
public
function
getSql
()
{
return
$this
->
_expression
;
}
/**
* __toString
*
* @return void
*/
public
function
__toString
()
{
return
$this
->
getSql
();
}
}
lib/Doctrine/Manager.php
deleted
100644 → 0
View file @
76abfb84
<?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>.
*/
/**
*
* Doctrine_Manager is the base component of all doctrine based projects.
* It opens and keeps track of all connections (database connections).
*
* @package Doctrine
* @subpackage Manager
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Remove.
*/
class
Doctrine_Manager
implements
Doctrine_Common_Configurable
,
Countable
,
IteratorAggregate
{
/**
* @var array $connections an array containing all the opened connections
*/
protected
$_connections
=
array
();
/**
* @var array $bound an array containing all components that have a bound connection
*/
protected
$_bound
=
array
();
/**
* @var integer $index the incremented index
*/
protected
$_index
=
0
;
/**
* @var integer $currIndex the current connection index
*/
protected
$_currIndex
=
0
;
/**
* @var string $root root directory
*/
protected
$_root
;
/**
* @var Doctrine_Query_Registry the query registry
*/
protected
$_queryRegistry
;
/**
*
*/
protected
static
$driverMap
=
array
(
'oci'
=>
'oracle'
);
/**
* constructor
*
* this is private constructor (use getInstance to get an instance of this class)
*/
private
function
__construct
()
{
$this
->
_root
=
dirname
(
__FILE__
);
}
/**
* setDefaultAttributes
* sets default attributes
*
* @todo I do not understand the flow here. Explain or refactor?
* @return boolean
*/
public
function
setDefaultAttributes
()
{
static
$init
=
false
;
if
(
!
$init
)
{
$init
=
true
;
$attributes
=
array
(
Doctrine
::
ATTR_RESULT_CACHE
=>
null
,
Doctrine
::
ATTR_QUERY_CACHE
=>
null
,
Doctrine
::
ATTR_LOAD_REFERENCES
=>
true
,
Doctrine
::
ATTR_LISTENER
=>
new
Doctrine_EventListener
(),
Doctrine
::
ATTR_RECORD_LISTENER
=>
null
,
Doctrine
::
ATTR_THROW_EXCEPTIONS
=>
true
,
Doctrine
::
ATTR_QUERY_LIMIT
=>
Doctrine
::
LIMIT_RECORDS
,
Doctrine
::
ATTR_IDXNAME_FORMAT
=>
"%s_idx"
,
Doctrine
::
ATTR_SEQNAME_FORMAT
=>
"%s_seq"
,
Doctrine
::
ATTR_TBLNAME_FORMAT
=>
"%s"
,
Doctrine
::
ATTR_QUOTE_IDENTIFIER
=>
false
,
Doctrine
::
ATTR_SEQCOL_NAME
=>
'id'
,
Doctrine
::
ATTR_PORTABILITY
=>
Doctrine
::
PORTABILITY_ALL
,
Doctrine
::
ATTR_EXPORT
=>
Doctrine
::
EXPORT_ALL
,
Doctrine
::
ATTR_DECIMAL_PLACES
=>
2
,
Doctrine
::
ATTR_DEFAULT_PARAM_NAMESPACE
=>
'doctrine'
);
foreach
(
$attributes
as
$attribute
=>
$value
)
{
$old
=
$this
->
getAttribute
(
$attribute
);
if
(
$old
===
null
)
{
$this
->
setAttribute
(
$attribute
,
$value
);
}
}
return
true
;
}
return
false
;
}
public
function
hasAttribute
(
$key
)
{
return
false
;
}
public
function
setAttribute
(
$name
,
$value
)
{}
public
function
getAttribute
(
$name
)
{
if
(
$name
==
Doctrine
::
ATTR_MODEL_LOADING
)
{
return
Doctrine
::
MODEL_LOADING_CONSERVATIVE
;
}
}
/**
* returns the root directory of Doctrine
*
* @return string
* @todo Better name.
*/
final
public
function
getRoot
()
{
return
$this
->
_root
;
}
/**
* getInstance
* returns an instance of this class
* (this class uses the singleton pattern)
*
* @return Doctrine_Manager
*/
public
static
function
getInstance
()
{
static
$instance
;
if
(
!
isset
(
$instance
))
{
$instance
=
new
self
();
}
return
$instance
;
}
/**
* getQueryRegistry
* lazy-initializes the query registry object and returns it
*
* @return Doctrine_Query_Registry
*/
public
function
getQueryRegistry
()
{
if
(
!
isset
(
$this
->
_queryRegistry
))
{
$this
->
_queryRegistry
=
new
Doctrine_Query_Registry
;
}
return
$this
->
_queryRegistry
;
}
/**
* setQueryRegistry
* sets the query registry
*
* @return Doctrine_Manager this object
*/
public
function
setQueryRegistry
(
Doctrine_Query_Registry
$registry
)
{
$this
->
_queryRegistry
=
$registry
;
return
$this
;
}
/**
* fetch
* fetches data using the provided queryKey and
* the associated query in the query registry
*
* if no query for given queryKey is being found a
* Doctrine_Query_Registry exception is being thrown
*
* @param string $queryKey the query key
* @param array $params prepared statement params (if any)
* @return mixed the fetched data
*/
public
function
find
(
$queryKey
,
$params
=
array
(),
$hydrationMode
=
Doctrine
::
HYDRATE_RECORD
)
{
return
Doctrine_Manager
::
getInstance
()
->
getQueryRegistry
()
->
get
(
$queryKey
)
->
execute
(
$params
,
$hydrationMode
);
}
/**
* fetchOne
* fetches data using the provided queryKey and
* the associated query in the query registry
*
* if no query for given queryKey is being found a
* Doctrine_Query_Registry exception is being thrown
*
* @param string $queryKey the query key
* @param array $params prepared statement params (if any)
* @return mixed the fetched data
*/
public
function
findOne
(
$queryKey
,
$params
=
array
(),
$hydrationMode
=
Doctrine
::
HYDRATE_RECORD
)
{
return
Doctrine_Manager
::
getInstance
()
->
getQueryRegistry
()
->
get
(
$queryKey
)
->
fetchOne
(
$params
,
$hydrationMode
);
}
/**
* connection
*
* if the adapter parameter is set this method acts as
* a short cut for Doctrine_Manager::getInstance()->openConnection($adapter, $name);
*
* if the adapter paramater is not set this method acts as
* a short cut for Doctrine_Manager::getInstance()->getCurrentConnection()
*
* @param PDO|Doctrine_Adapter_Interface $adapter database driver
* @param string $name name of the connection, if empty numeric key is used
* @throws Doctrine_Manager_Exception if trying to bind a connection with an existing name
* @return Doctrine_Connection
*/
public
static
function
connection
(
$adapter
=
null
,
$name
=
null
)
{
if
(
$adapter
==
null
)
{
return
Doctrine_Manager
::
getInstance
()
->
getCurrentConnection
();
}
else
{
return
Doctrine_Manager
::
getInstance
()
->
openConnection
(
$adapter
,
$name
);
}
}
/**
* openConnection
* opens a new connection and saves it to Doctrine_Manager->connections
*
* @param PDO|Doctrine_Adapter_Interface $adapter database driver
* @param string $name name of the connection, if empty numeric key is used
* @throws Doctrine_Manager_Exception if trying to bind a connection with an existing name
* @throws Doctrine_Manager_Exception if trying to open connection for unknown driver
* @return Doctrine_Connection
*/
public
function
openConnection
(
$adapter
,
$name
=
null
,
$setCurrent
=
true
)
{
if
(
is_object
(
$adapter
))
{
if
(
!
(
$adapter
instanceof
PDO
)
&&
!
in_array
(
'Doctrine_Adapter_Interface'
,
class_implements
(
$adapter
)))
{
throw
new
Doctrine_Manager_Exception
(
"First argument should be an instance of PDO or implement Doctrine_Adapter_Interface"
);
}
$driverName
=
$adapter
->
getAttribute
(
Doctrine
::
ATTR_DRIVER_NAME
);
}
else
if
(
is_array
(
$adapter
))
{
if
(
!
isset
(
$adapter
[
0
]))
{
throw
new
Doctrine_Manager_Exception
(
'Empty data source name given.'
);
}
$e
=
explode
(
':'
,
$adapter
[
0
]);
if
(
$e
[
0
]
==
'uri'
)
{
$e
[
0
]
=
'odbc'
;
}
$parts
[
'dsn'
]
=
$adapter
[
0
];
$parts
[
'scheme'
]
=
$e
[
0
];
$parts
[
'user'
]
=
(
isset
(
$adapter
[
1
]))
?
$adapter
[
1
]
:
null
;
$parts
[
'pass'
]
=
(
isset
(
$adapter
[
2
]))
?
$adapter
[
2
]
:
null
;
$driverName
=
$e
[
0
];
$adapter
=
$parts
;
}
else
{
$parts
=
$this
->
parseDsn
(
$adapter
);
$driverName
=
$parts
[
'scheme'
];
$adapter
=
$parts
;
}
// initialize the default attributes
$this
->
setDefaultAttributes
();
if
(
$name
!==
null
)
{
$name
=
(
string
)
$name
;
if
(
isset
(
$this
->
_connections
[
$name
]))
{
if
(
$setCurrent
)
{
$this
->
_currIndex
=
$name
;
}
return
$this
->
_connections
[
$name
];
}
}
else
{
$name
=
$this
->
_index
;
$this
->
_index
++
;
}
$drivers
=
array
(
'mysql'
=>
'Doctrine_Connection_Mysql'
,
'sqlite'
=>
'Doctrine_Connection_Sqlite'
,
'pgsql'
=>
'Doctrine_Connection_Pgsql'
,
'oci'
=>
'Doctrine_Connection_Oracle'
,
'oci8'
=>
'Doctrine_Connection_Oracle'
,
'oracle'
=>
'Doctrine_Connection_Oracle'
,
'mssql'
=>
'Doctrine_Connection_Mssql'
,
'dblib'
=>
'Doctrine_Connection_Mssql'
,
'firebird'
=>
'Doctrine_Connection_Firebird'
,
'informix'
=>
'Doctrine_Connection_Informix'
,
'mock'
=>
'Doctrine_Connection_Mock'
);
if
(
!
isset
(
$drivers
[
$driverName
]))
{
throw
new
Doctrine_Manager_Exception
(
'Unknown driver '
.
$driverName
);
}
$className
=
$drivers
[
$driverName
];
$conn
=
new
$className
(
$adapter
);
$conn
->
setName
(
$name
);
$this
->
_connections
[
$name
]
=
$conn
;
if
(
$setCurrent
)
{
$this
->
_currIndex
=
$name
;
}
return
$this
->
_connections
[
$name
];
}
/**
* parsePdoDsn
*
* @param array $dsn An array of dsn information
* @return array The array parsed
* @todo package:dbal
*/
public
function
parsePdoDsn
(
$dsn
)
{
$parts
=
array
();
$names
=
array
(
'dsn'
,
'scheme'
,
'host'
,
'port'
,
'user'
,
'pass'
,
'path'
,
'query'
,
'fragment'
);
foreach
(
$names
as
$name
)
{
if
(
!
isset
(
$parts
[
$name
]))
{
$parts
[
$name
]
=
null
;
}
}
$e
=
explode
(
':'
,
$dsn
);
$parts
[
'scheme'
]
=
$e
[
0
];
$parts
[
'dsn'
]
=
$dsn
;
$e
=
explode
(
';'
,
$e
[
1
]);
foreach
(
$e
as
$string
)
{
if
(
$string
)
{
$e2
=
explode
(
'='
,
$string
);
if
(
isset
(
$e2
[
0
])
&&
isset
(
$e2
[
1
]))
{
list
(
$key
,
$value
)
=
$e2
;
$parts
[
$key
]
=
$value
;
}
}
}
return
$parts
;
}
/**
* parseDsn
*
* @param string $dsn
* @return array Parsed contents of DSN
* @todo package:dbal
*/
public
function
parseDsn
(
$dsn
)
{
// fix sqlite dsn so that it will parse correctly
if
(
false
!==
strpos
(
$dsn
,
':///'
))
{
// replace windows directory separators
$dsn
=
str_replace
(
"
\\
"
,
"/"
,
$dsn
);
// replace file:/// format with parse_url()-compatible file://
$dsn
=
str_replace
(
":///"
,
"://"
,
$dsn
);
}
// silence any warnings
$parts
=
@
parse_url
(
$dsn
);
$names
=
array
(
'dsn'
,
'scheme'
,
'host'
,
'port'
,
'user'
,
'pass'
,
'path'
,
'query'
,
'fragment'
);
foreach
(
$names
as
$name
)
{
if
(
!
isset
(
$parts
[
$name
]))
{
$parts
[
$name
]
=
null
;
}
}
if
(
count
(
$parts
)
==
0
||
!
isset
(
$parts
[
'scheme'
]))
{
throw
new
Doctrine_Manager_Exception
(
'Empty data source name'
);
}
switch
(
$parts
[
'scheme'
])
{
case
'sqlite'
:
case
'sqlite2'
:
case
'sqlite3'
:
if
(
isset
(
$parts
[
'host'
])
&&
$parts
[
'host'
]
==
':memory'
)
{
$parts
[
'database'
]
=
':memory:'
;
$parts
[
'dsn'
]
=
'sqlite::memory:'
;
}
else
{
//fix windows dsn we have to add host: to path and set host to null
if
(
isset
(
$parts
[
'host'
]))
{
$parts
[
'path'
]
=
$parts
[
'host'
]
.
":"
.
$parts
[
"path"
];
$parts
[
"host"
]
=
null
;
}
$parts
[
'database'
]
=
$parts
[
'path'
];
$parts
[
'dsn'
]
=
$parts
[
'scheme'
]
.
':'
.
$parts
[
'path'
];
}
break
;
case
'mssql'
:
case
'dblib'
:
if
(
!
isset
(
$parts
[
'path'
])
||
$parts
[
'path'
]
==
'/'
)
{
throw
new
Doctrine_Manager_Exception
(
'No database available in data source name'
);
}
if
(
isset
(
$parts
[
'path'
]))
{
$parts
[
'database'
]
=
substr
(
$parts
[
'path'
],
1
);
}
if
(
!
isset
(
$parts
[
'host'
]))
{
throw
new
Doctrine_Manager_Exception
(
'No hostname set in data source name'
);
}
if
(
isset
(
self
::
$driverMap
[
$parts
[
'scheme'
]]))
{
$parts
[
'scheme'
]
=
self
::
$driverMap
[
$parts
[
'scheme'
]];
}
$parts
[
'dsn'
]
=
$parts
[
'scheme'
]
.
':host='
.
$parts
[
'host'
]
.
(
isset
(
$parts
[
'port'
])
?
':'
.
$parts
[
'port'
]
:
null
)
.
';dbname='
.
$parts
[
'database'
];
break
;
case
'mysql'
:
case
'informix'
:
case
'oci8'
:
case
'oci'
:
case
'firebird'
:
case
'pgsql'
:
case
'odbc'
:
case
'mock'
:
case
'oracle'
:
if
(
!
isset
(
$parts
[
'path'
])
||
$parts
[
'path'
]
==
'/'
)
{
throw
new
Doctrine_Manager_Exception
(
'No database available in data source name'
);
}
if
(
isset
(
$parts
[
'path'
]))
{
$parts
[
'database'
]
=
substr
(
$parts
[
'path'
],
1
);
}
if
(
!
isset
(
$parts
[
'host'
]))
{
throw
new
Doctrine_Manager_Exception
(
'No hostname set in data source name'
);
}
if
(
isset
(
self
::
$driverMap
[
$parts
[
'scheme'
]]))
{
$parts
[
'scheme'
]
=
self
::
$driverMap
[
$parts
[
'scheme'
]];
}
$parts
[
'dsn'
]
=
$parts
[
'scheme'
]
.
':host='
.
$parts
[
'host'
]
.
(
isset
(
$parts
[
'port'
])
?
';port='
.
$parts
[
'port'
]
:
null
)
.
';dbname='
.
$parts
[
'database'
];
break
;
default
:
throw
new
Doctrine_Manager_Exception
(
'Unknown driver '
.
$parts
[
'scheme'
]);
}
return
$parts
;
}
/**
* getConnection
* @param integer $index
* @return object Doctrine_Connection
* @throws Doctrine_Manager_Exception if trying to get a non-existent connection
*/
public
function
getConnection
(
$name
)
{
if
(
!
isset
(
$this
->
_connections
[
$name
]))
{
throw
new
Doctrine_Manager_Exception
(
'Unknown connection: '
.
$name
);
}
return
$this
->
_connections
[
$name
];
}
/**
* Creates a new Doctrine_Query object that uses the currently active connection.
*
* @return Doctrine_Query
*/
public
function
createQuery
(
$dql
=
""
)
{
$query
=
new
Doctrine_Query
(
$this
->
getCurrentConnection
());
if
(
!
empty
(
$dql
))
{
$query
->
parseQuery
(
$dql
);
}
return
$query
;
}
/**
* Creates a new native (SQL) query.
*
* @return Doctrine_RawSql
*/
public
function
createNativeQuery
(
$sql
=
""
)
{
$nativeQuery
=
new
Doctrine_RawSql
(
$this
->
getCurrentConnection
());
if
(
!
empty
(
$sql
))
{
$nativeQuery
->
parseQuery
(
$sql
);
}
return
$nativeQuery
;
}
/**
* Creates a query object out of a registered, named query.
*
* @param string $name The name of the query.
* @return Doctrine_Query The query object.
*/
public
function
createNamedQuery
(
$name
)
{
return
$this
->
_queryRegistry
->
get
(
$name
);
}
/**
* getComponentAlias
* retrieves the alias for given component name
* if the alias couldn't be found, this method returns the given
* component name
*
* @param string $componentName
* @return string the component alias
*/
public
function
getComponentAlias
(
$componentName
)
{
if
(
isset
(
$this
->
componentAliases
[
$componentName
]))
{
return
$this
->
componentAliases
[
$componentName
];
}
return
$componentName
;
}
/**
* sets an alias for given component name
* very useful when building a large framework with a possibility
* to override any given class
*
* @param string $componentName the name of the component
* @param string $alias
* @return Doctrine_Manager
*/
public
function
setComponentAlias
(
$componentName
,
$alias
)
{
$this
->
componentAliases
[
$componentName
]
=
$alias
;
return
$this
;
}
/**
* getConnectionName
*
* @param Doctrine_Connection $conn connection object to be searched for
* @return string the name of the connection
*/
public
function
getConnectionName
(
Doctrine_Connection
$conn
)
{
return
array_search
(
$conn
,
$this
->
_connections
,
true
);
}
/**
* bindComponent
* binds given component to given connection
* this means that when ever the given component uses a connection
* it will be using the bound connection instead of the current connection
*
* @param string $componentName
* @param string $connectionName
* @return boolean
*/
public
function
bindComponent
(
$componentName
,
$connectionName
)
{
$this
->
_bound
[
$componentName
]
=
$connectionName
;
}
/**
* getConnectionForComponent
*
* @param string $componentName
* @return Doctrine_Connection
*/
public
function
getConnectionForComponent
(
$componentName
=
null
)
{
if
(
isset
(
$this
->
_bound
[
$componentName
]))
{
return
$this
->
getConnection
(
$this
->
_bound
[
$componentName
]);
}
return
$this
->
getCurrentConnection
();
}
/**
* hasConnectionForComponent
*
* @param string $componentName
* @return boolean
*/
public
function
hasConnectionForComponent
(
$componentName
=
null
)
{
return
isset
(
$this
->
_bound
[
$componentName
]);
}
/**
* getTable
* this is the same as Doctrine_Connection::getTable() except
* that it works seamlessly in multi-server/connection environment
*
* @see Doctrine_Connection::getTable()
* @param string $componentName
* @return Doctrine_Table
* @deprecated
*/
public
function
getTable
(
$componentName
)
{
return
$this
->
getConnectionForComponent
(
$componentName
)
->
getTable
(
$componentName
);
}
/**
* getMapper
* Returns the mapper object for the given component name.
*
* @param string $componentName
* @return Doctrine_Mapper
*/
public
function
getMapper
(
$componentName
)
{
return
$this
->
getConnectionForComponent
(
$componentName
)
->
getEntityPersister
(
$componentName
);
}
/**
* table
* this is the same as Doctrine_Connection::getTable() except
* that it works seamlessly in multi-server/connection environment
*
* @see Doctrine_Connection::getTable()
* @param string $componentName
* @return Doctrine_Table
*/
public
static
function
table
(
$componentName
)
{
return
Doctrine_Manager
::
getInstance
()
->
getConnectionForComponent
(
$componentName
)
->
getTable
(
$componentName
);
}
/**
* closes the connection
*
* @param Doctrine_Connection $connection
* @return void
*/
public
function
closeConnection
(
Doctrine_Connection
$connection
)
{
$connection
->
close
();
$key
=
array_search
(
$connection
,
$this
->
_connections
,
true
);
if
(
$key
!==
false
)
{
unset
(
$this
->
_connections
[
$key
]);
}
$this
->
_currIndex
=
key
(
$this
->
_connections
);
unset
(
$connection
);
}
/**
* getConnections
* returns all opened connections
*
* @return array
*/
public
function
getConnections
()
{
return
$this
->
_connections
;
}
/**
* setCurrentConnection
* sets the current connection to $key
*
* @param mixed $key the connection key
* @throws InvalidKeyException
* @return void
*/
public
function
setCurrentConnection
(
$key
)
{
$key
=
(
string
)
$key
;
if
(
!
isset
(
$this
->
_connections
[
$key
]))
{
throw
new
InvalidKeyException
();
}
$this
->
_currIndex
=
$key
;
}
/**
* contains
* whether or not the manager contains specified connection
*
* @param mixed $key the connection key
* @return boolean
*/
public
function
contains
(
$key
)
{
return
isset
(
$this
->
_connections
[
$key
]);
}
/**
* count
* returns the number of opened connections
*
* @return integer
* @todo This is unintuitive.
*/
public
function
count
()
{
return
count
(
$this
->
_connections
);
}
/**
* getIterator
* returns an ArrayIterator that iterates through all connections
*
* @return ArrayIterator
*/
public
function
getIterator
()
{
return
new
ArrayIterator
(
$this
->
_connections
);
}
/**
* getCurrentConnection
* returns the current connection
*
* @throws Doctrine_Connection_Exception if there are no open connections
* @return Doctrine_Connection
*/
public
function
getCurrentConnection
()
{
$i
=
$this
->
_currIndex
;
if
(
!
isset
(
$this
->
_connections
[
$i
]))
{
throw
new
Doctrine_Connection_Exception
();
}
return
$this
->
_connections
[
$i
];
}
/**
* createDatabases
*
* Creates databases for connections
*
* @param string $specifiedConnections Array of connections you wish to create the database for
* @return void
* @todo package:dbal
*/
public
function
createDatabases
(
$specifiedConnections
=
array
())
{
if
(
!
is_array
(
$specifiedConnections
))
{
$specifiedConnections
=
(
array
)
$specifiedConnections
;
}
$results
=
array
();
foreach
(
$this
as
$name
=>
$connection
)
{
if
(
!
empty
(
$specifiedConnections
)
&&
!
in_array
(
$name
,
$specifiedConnections
))
{
continue
;
}
$results
[
$name
]
=
$connection
->
createDatabase
();
}
return
$results
;
}
/**
* dropDatabases
*
* Drops databases for connections
*
* @param string $specifiedConnections Array of connections you wish to drop the database for
* @return void
* @todo package:dbal
*/
public
function
dropDatabases
(
$specifiedConnections
=
array
())
{
if
(
!
is_array
(
$specifiedConnections
))
{
$specifiedConnections
=
(
array
)
$specifiedConnections
;
}
$results
=
array
();
foreach
(
$this
as
$name
=>
$connection
)
{
if
(
!
empty
(
$specifiedConnections
)
&&
!
in_array
(
$name
,
$specifiedConnections
))
{
continue
;
}
$results
[
$name
]
=
$connection
->
dropDatabase
();
}
return
$results
;
}
/**
* __toString
* returns a string representation of this object
*
* @return string
*/
public
function
__toString
()
{
$r
[]
=
"<pre>"
;
$r
[]
=
"Doctrine_Manager"
;
$r
[]
=
"Connections : "
.
count
(
$this
->
_connections
);
$r
[]
=
"</pre>"
;
return
implode
(
"
\n
"
,
$r
);
}
}
lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
View file @
580f21c4
...
@@ -54,7 +54,7 @@ abstract class Doctrine_ORM_Internal_Hydration_AbstractHydrator
...
@@ -54,7 +54,7 @@ abstract class Doctrine_ORM_Internal_Hydration_AbstractHydrator
/**
/**
* The current hydration mode.
* The current hydration mode.
*/
*/
protected
$_hydrationMode
=
Doctrine
::
HYDRATE_RECORD
;
protected
$_hydrationMode
=
Doctrine
_Query
::
HYDRATE_OBJECT
;
protected
$_nullObject
;
protected
$_nullObject
;
...
...
lib/Doctrine/ORM/Internal/Hydration/StandardHydrator.php
View file @
580f21c4
...
@@ -89,14 +89,14 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
...
@@ -89,14 +89,14 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
$stmt
=
$parserResult
->
getDatabaseStatement
();
$stmt
=
$parserResult
->
getDatabaseStatement
();
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_NONE
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_NONE
)
{
return
$stmt
->
fetchAll
(
PDO
::
FETCH_NUM
);
return
$stmt
->
fetchAll
(
PDO
::
FETCH_NUM
);
}
}
$this
->
_tableAliases
=
$parserResult
->
getTableToClassAliasMap
();
$this
->
_tableAliases
=
$parserResult
->
getTableToClassAliasMap
();
$this
->
_queryComponents
=
$parserResult
->
getQueryComponents
();
$this
->
_queryComponents
=
$parserResult
->
getQueryComponents
();
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
)
{
$driver
=
new
Doctrine_ORM_Internal_Hydration_ArrayDriver
();
$driver
=
new
Doctrine_ORM_Internal_Hydration_ArrayDriver
();
}
else
{
}
else
{
$driver
=
new
Doctrine_ORM_Internal_Hydration_ObjectDriver
(
$this
->
_em
);
$driver
=
new
Doctrine_ORM_Internal_Hydration_ObjectDriver
(
$this
->
_em
);
...
@@ -123,7 +123,7 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
...
@@ -123,7 +123,7 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
$idTemplate
=
array
();
$idTemplate
=
array
();
// Holds the resulting hydrated data structure
// Holds the resulting hydrated data structure
if
(
$parserResult
->
isMixedQuery
()
||
$hydrationMode
==
Doctrine
::
HYDRATE_SCALAR
)
{
if
(
$parserResult
->
isMixedQuery
()
||
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_SCALAR
)
{
$result
=
array
();
$result
=
array
();
}
else
{
}
else
{
$result
=
$driver
->
getElementCollection
(
$rootEntityName
);
$result
=
$driver
->
getElementCollection
(
$rootEntityName
);
...
@@ -145,7 +145,7 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
...
@@ -145,7 +145,7 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
$cache
=
array
();
$cache
=
array
();
// Evaluate HYDRATE_SINGLE_SCALAR
// Evaluate HYDRATE_SINGLE_SCALAR
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_SINGLE_SCALAR
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_SINGLE_SCALAR
)
{
$result
=
$stmt
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
$result
=
$stmt
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
if
(
count
(
$result
)
>
1
||
count
(
$result
[
0
])
>
1
)
{
if
(
count
(
$result
)
>
1
||
count
(
$result
[
0
])
>
1
)
{
throw
Doctrine_ORM_Exceptions_HydrationException
::
nonUniqueResult
();
throw
Doctrine_ORM_Exceptions_HydrationException
::
nonUniqueResult
();
...
@@ -154,9 +154,9 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
...
@@ -154,9 +154,9 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
}
}
// Process result set
// Process result set
while
(
$data
=
$stmt
->
fetch
(
Doctrine
::
FETCH_ASSOC
))
{
while
(
$data
=
$stmt
->
fetch
(
PDO
::
FETCH_ASSOC
))
{
// Evaluate HYDRATE_SCALAR
// Evaluate HYDRATE_SCALAR
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_SCALAR
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_SCALAR
)
{
$result
[]
=
$this
->
_gatherScalarRowData
(
$data
,
$cache
);
$result
[]
=
$this
->
_gatherScalarRowData
(
$data
,
$cache
);
continue
;
continue
;
}
}
...
...
lib/Doctrine/Query.php
View file @
580f21c4
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
* <http://www.phpdoctrine.org>.
* <http://www.phpdoctrine.org>.
*/
*/
#namespace Doctrine::ORM;
/**
/**
* A Doctrine_Query object represents a DQL query. It is used to query databases for
* A Doctrine_Query object represents a DQL query. It is used to query databases for
* data in an object-oriented fashion. A DQL query understands relations and inheritance
* data in an object-oriented fashion. A DQL query understands relations and inheritance
...
@@ -36,6 +38,28 @@
...
@@ -36,6 +38,28 @@
*/
*/
class
Doctrine_Query
extends
Doctrine_Query_Abstract
class
Doctrine_Query
extends
Doctrine_Query_Abstract
{
{
/* Hydration mode constants */
/**
* Hydrates an object graph. This is the default behavior.
*/
const
HYDRATE_OBJECT
=
1
;
/**
* Hydrates an array graph.
*/
const
HYDRATE_ARRAY
=
2
;
/**
* Hydrates a flat, rectangular result set with scalar values.
*/
const
HYDRATE_SCALAR
=
3
;
/**
* Hydrates a single scalar value.
*/
const
HYDRATE_SINGLE_SCALAR
=
4
;
/**
* Hydrates nothing.
*/
const
HYDRATE_NONE
=
5
;
/**
/**
* @var Doctrine_EntityManager The entity manager used by this query object.
* @var Doctrine_EntityManager The entity manager used by this query object.
*/
*/
...
@@ -54,7 +78,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract
...
@@ -54,7 +78,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract
/**
/**
* @var string $_sql Cached SQL query.
* @var string $_sql Cached SQL query.
*/
*/
protected
$_sql
=
null
;
protected
$_sql
;
// Caching Stuff
// Caching Stuff
...
...
lib/Doctrine/Query/ParserRule.php
View file @
580f21c4
...
@@ -151,7 +151,8 @@ abstract class Doctrine_Query_ParserRule
...
@@ -151,7 +151,8 @@ abstract class Doctrine_Query_ParserRule
$class
=
'Doctrine_Query_Parser_'
.
$name
;
$class
=
'Doctrine_Query_Parser_'
.
$name
;
//echo $class . "\r\n";
//echo $class . "\r\n";
//TODO: This expensive check is not necessary. Should be removed at the end.
// "new $class" will throw an error anyway if the class is not found.
if
(
!
class_exists
(
$class
))
{
if
(
!
class_exists
(
$class
))
{
throw
new
Doctrine_Query_Parser_Exception
(
throw
new
Doctrine_Query_Parser_Exception
(
"Unknown Grammar Rule '
$name
'. Could not find related compiler class."
"Unknown Grammar Rule '
$name
'. Could not find related compiler class."
...
...
tests/Orm/Hydration/BasicHydrationTest.php
View file @
580f21c4
...
@@ -16,9 +16,9 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -16,9 +16,9 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
public
static
function
hydrationModeProvider
()
public
static
function
hydrationModeProvider
()
{
{
return
array
(
return
array
(
array
(
'hydrationMode'
=>
Doctrine
::
HYDRATE_RECORD
),
array
(
'hydrationMode'
=>
Doctrine
_Query
::
HYDRATE_OBJECT
),
array
(
'hydrationMode'
=>
Doctrine
::
HYDRATE_ARRAY
),
array
(
'hydrationMode'
=>
Doctrine
_Query
::
HYDRATE_ARRAY
),
array
(
'hydrationMode'
=>
Doctrine
::
HYDRATE_SCALAR
)
array
(
'hydrationMode'
=>
Doctrine
_Query
::
HYDRATE_SCALAR
)
);
);
}
}
...
@@ -76,7 +76,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -76,7 +76,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$stmt
,
$queryComponents
,
$tableAliasMap
,
$hydrationMode
));
$stmt
,
$queryComponents
,
$tableAliasMap
,
$hydrationMode
));
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
||
$hydrationMode
==
Doctrine
::
HYDRATE_RECORD
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
||
$hydrationMode
==
Doctrine_Query
::
HYDRATE_OBJECT
)
{
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertEquals
(
1
,
$result
[
0
][
'id'
]);
$this
->
assertEquals
(
1
,
$result
[
0
][
'id'
]);
$this
->
assertEquals
(
'romanb'
,
$result
[
0
][
'name'
]);
$this
->
assertEquals
(
'romanb'
,
$result
[
0
][
'name'
]);
...
@@ -84,13 +84,13 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -84,13 +84,13 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this
->
assertEquals
(
'jwage'
,
$result
[
1
][
'name'
]);
$this
->
assertEquals
(
'jwage'
,
$result
[
1
][
'name'
]);
}
}
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_RECORD
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_OBJECT
)
{
$this
->
assertTrue
(
$result
instanceof
Doctrine_ORM_Collection
);
$this
->
assertTrue
(
$result
instanceof
Doctrine_ORM_Collection
);
$this
->
assertTrue
(
$result
[
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
]
instanceof
Doctrine_ORM_Entity
);
}
else
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
)
{
}
else
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
)
{
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
));
}
else
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_SCALAR
)
{
}
else
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_SCALAR
)
{
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertEquals
(
'romanb'
,
$result
[
0
][
'u_name'
]);
$this
->
assertEquals
(
'romanb'
,
$result
[
0
][
'u_name'
]);
...
@@ -163,11 +163,11 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -163,11 +163,11 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$stmt
,
$queryComponents
,
$tableAliasMap
,
$hydrationMode
,
true
));
$stmt
,
$queryComponents
,
$tableAliasMap
,
$hydrationMode
,
true
));
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
)
{
//var_dump($result);
//var_dump($result);
}
}
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
||
$hydrationMode
==
Doctrine
::
HYDRATE_RECORD
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
||
$hydrationMode
==
Doctrine_Query
::
HYDRATE_OBJECT
)
{
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
[
0
]));
$this
->
assertTrue
(
is_array
(
$result
[
0
]));
...
@@ -185,14 +185,14 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -185,14 +185,14 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this
->
assertEquals
(
91
,
$result
[
1
][
0
][
'phonenumbers'
][
0
][
'phonenumber'
]);
$this
->
assertEquals
(
91
,
$result
[
1
][
0
][
'phonenumbers'
][
0
][
'phonenumber'
]);
}
}
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_RECORD
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_OBJECT
)
{
$this
->
assertTrue
(
$result
[
0
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
0
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
0
][
0
][
'phonenumbers'
]
instanceof
Doctrine_ORM_Collection
);
$this
->
assertTrue
(
$result
[
0
][
0
][
'phonenumbers'
]
instanceof
Doctrine_ORM_Collection
);
$this
->
assertTrue
(
$result
[
0
][
0
][
'phonenumbers'
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
0
][
0
][
'phonenumbers'
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
0
][
0
][
'phonenumbers'
][
1
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
0
][
0
][
'phonenumbers'
][
1
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
][
0
][
'phonenumbers'
]
instanceof
Doctrine_ORM_Collection
);
$this
->
assertTrue
(
$result
[
1
][
0
][
'phonenumbers'
]
instanceof
Doctrine_ORM_Collection
);
}
else
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_SCALAR
)
{
}
else
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_SCALAR
)
{
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertEquals
(
3
,
count
(
$result
));
$this
->
assertEquals
(
3
,
count
(
$result
));
$this
->
assertEquals
(
1
,
$result
[
0
][
'u_id'
]);
$this
->
assertEquals
(
1
,
$result
[
0
][
'u_id'
]);
...
@@ -260,7 +260,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -260,7 +260,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$stmt
,
$queryComponents
,
$tableAliasMap
,
$hydrationMode
,
true
));
$stmt
,
$queryComponents
,
$tableAliasMap
,
$hydrationMode
,
true
));
//var_dump($result);
//var_dump($result);
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
||
$hydrationMode
==
Doctrine
::
HYDRATE_RECORD
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
||
$hydrationMode
==
Doctrine_Query
::
HYDRATE_OBJECT
)
{
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
[
0
]));
$this
->
assertTrue
(
is_array
(
$result
[
0
]));
...
@@ -272,10 +272,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -272,10 +272,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this
->
assertEquals
(
1
,
$result
[
1
][
'numPhones'
]);
$this
->
assertEquals
(
1
,
$result
[
1
][
'numPhones'
]);
}
}
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_RECORD
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_OBJECT
)
{
$this
->
assertTrue
(
$result
[
0
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
0
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
][
0
]
instanceof
Doctrine_ORM_Entity
);
}
else
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_SCALAR
)
{
}
else
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_SCALAR
)
{
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertEquals
(
1
,
$result
[
0
][
'u_id'
]);
$this
->
assertEquals
(
1
,
$result
[
0
][
'u_id'
]);
...
@@ -355,7 +355,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -355,7 +355,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
//var_dump($result);
//var_dump($result);
}
}
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
||
$hydrationMode
==
Doctrine
::
HYDRATE_RECORD
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
||
$hydrationMode
==
Doctrine_Query
::
HYDRATE_OBJECT
)
{
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
[
0
]));
$this
->
assertTrue
(
is_array
(
$result
[
0
]));
...
@@ -376,12 +376,12 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -376,12 +376,12 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this
->
assertEquals
(
'JWAGE'
,
$result
[
1
][
'nameUpper'
]);
$this
->
assertEquals
(
'JWAGE'
,
$result
[
1
][
'nameUpper'
]);
}
}
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_RECORD
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_OBJECT
)
{
$this
->
assertTrue
(
$result
[
0
][
'1'
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
0
][
'1'
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
][
'2'
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
][
'2'
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
0
][
'1'
][
'phonenumbers'
]
instanceof
Doctrine_ORM_Collection
);
$this
->
assertTrue
(
$result
[
0
][
'1'
][
'phonenumbers'
]
instanceof
Doctrine_ORM_Collection
);
$this
->
assertEquals
(
2
,
count
(
$result
[
0
][
'1'
][
'phonenumbers'
]));
$this
->
assertEquals
(
2
,
count
(
$result
[
0
][
'1'
][
'phonenumbers'
]));
}
else
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_SCALAR
)
{
}
else
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_SCALAR
)
{
// NOTE: Indexing has no effect with HYDRATE_SCALAR
// NOTE: Indexing has no effect with HYDRATE_SCALAR
//... asserts to come
//... asserts to come
}
}
...
@@ -491,11 +491,11 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -491,11 +491,11 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$stmt
,
$queryComponents
,
$tableAliasMap
,
$hydrationMode
,
true
));
$stmt
,
$queryComponents
,
$tableAliasMap
,
$hydrationMode
,
true
));
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
)
{
//var_dump($result);
//var_dump($result);
}
}
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
||
$hydrationMode
==
Doctrine
::
HYDRATE_RECORD
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
||
$hydrationMode
==
Doctrine_Query
::
HYDRATE_OBJECT
)
{
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
[
0
]));
$this
->
assertTrue
(
is_array
(
$result
[
0
]));
...
@@ -520,7 +520,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -520,7 +520,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this
->
assertEquals
(
'PHP6'
,
$result
[
1
][
0
][
'articles'
][
1
][
'topic'
]);
$this
->
assertEquals
(
'PHP6'
,
$result
[
1
][
0
][
'articles'
][
1
][
'topic'
]);
}
}
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_RECORD
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_OBJECT
)
{
$this
->
assertTrue
(
$result
[
0
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
0
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
0
][
0
][
'phonenumbers'
]
instanceof
Doctrine_ORM_Collection
);
$this
->
assertTrue
(
$result
[
0
][
0
][
'phonenumbers'
]
instanceof
Doctrine_ORM_Collection
);
$this
->
assertTrue
(
$result
[
0
][
0
][
'phonenumbers'
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
0
][
0
][
'phonenumbers'
][
0
]
instanceof
Doctrine_ORM_Entity
);
...
@@ -533,7 +533,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -533,7 +533,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this
->
assertTrue
(
$result
[
1
][
0
][
'phonenumbers'
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
][
0
][
'phonenumbers'
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
][
0
][
'articles'
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
][
0
][
'articles'
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
][
0
][
'articles'
][
1
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
][
0
][
'articles'
][
1
]
instanceof
Doctrine_ORM_Entity
);
}
else
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_SCALAR
)
{
}
else
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_SCALAR
)
{
//...
//...
$this
->
assertEquals
(
6
,
count
(
$result
));
$this
->
assertEquals
(
6
,
count
(
$result
));
//var_dump($result);
//var_dump($result);
...
@@ -666,11 +666,11 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -666,11 +666,11 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$stmt
,
$queryComponents
,
$tableAliasMap
,
$hydrationMode
,
true
));
$stmt
,
$queryComponents
,
$tableAliasMap
,
$hydrationMode
,
true
));
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
)
{
//var_dump($result);
//var_dump($result);
}
}
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
||
$hydrationMode
==
Doctrine
::
HYDRATE_RECORD
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
||
$hydrationMode
==
Doctrine_Query
::
HYDRATE_OBJECT
)
{
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
[
0
]));
$this
->
assertTrue
(
is_array
(
$result
[
0
]));
...
@@ -704,7 +704,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -704,7 +704,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this
->
assertTrue
(
isset
(
$result
[
1
][
0
][
'articles'
][
1
][
'comments'
]));
$this
->
assertTrue
(
isset
(
$result
[
1
][
0
][
'articles'
][
1
][
'comments'
]));
}
}
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_RECORD
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_OBJECT
)
{
$this
->
assertTrue
(
$result
[
0
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
0
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
][
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
][
0
]
instanceof
Doctrine_ORM_Entity
);
// phonenumbers
// phonenumbers
...
@@ -729,9 +729,9 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -729,9 +729,9 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this
->
assertEquals
(
0
,
count
(
$result
[
1
][
0
][
'articles'
][
0
][
'comments'
]));
$this
->
assertEquals
(
0
,
count
(
$result
[
1
][
0
][
'articles'
][
0
][
'comments'
]));
$this
->
assertTrue
(
$result
[
1
][
0
][
'articles'
][
1
][
'comments'
]
instanceof
Doctrine_ORM_Collection
);
$this
->
assertTrue
(
$result
[
1
][
0
][
'articles'
][
1
][
'comments'
]
instanceof
Doctrine_ORM_Collection
);
$this
->
assertEquals
(
0
,
count
(
$result
[
1
][
0
][
'articles'
][
1
][
'comments'
]));
$this
->
assertEquals
(
0
,
count
(
$result
[
1
][
0
][
'articles'
][
1
][
'comments'
]));
}
else
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_SCALAR
)
{
}
else
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_SCALAR
)
{
//...
//...
}
else
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
)
{
}
else
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
)
{
//...
//...
// empty comment collections
// empty comment collections
...
@@ -831,11 +831,11 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -831,11 +831,11 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$stmt
,
$queryComponents
,
$tableAliasMap
,
$hydrationMode
));
$stmt
,
$queryComponents
,
$tableAliasMap
,
$hydrationMode
));
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
)
{
//var_dump($result);
//var_dump($result);
}
}
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
||
$hydrationMode
==
Doctrine
::
HYDRATE_RECORD
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
||
$hydrationMode
==
Doctrine_Query
::
HYDRATE_OBJECT
)
{
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertTrue
(
isset
(
$result
[
0
][
'boards'
]));
$this
->
assertTrue
(
isset
(
$result
[
0
][
'boards'
]));
$this
->
assertEquals
(
3
,
count
(
$result
[
0
][
'boards'
]));
$this
->
assertEquals
(
3
,
count
(
$result
[
0
][
'boards'
]));
...
@@ -843,15 +843,15 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -843,15 +843,15 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this
->
assertEquals
(
1
,
count
(
$result
[
1
][
'boards'
]));
$this
->
assertEquals
(
1
,
count
(
$result
[
1
][
'boards'
]));
}
}
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_ARRAY
)
{
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_ARRAY
)
{
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
));
$this
->
assertTrue
(
is_array
(
$result
[
0
]));
$this
->
assertTrue
(
is_array
(
$result
[
0
]));
$this
->
assertTrue
(
is_array
(
$result
[
1
]));
$this
->
assertTrue
(
is_array
(
$result
[
1
]));
}
else
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_RECORD
)
{
}
else
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_OBJECT
)
{
$this
->
assertTrue
(
$result
instanceof
Doctrine_ORM_Collection
);
$this
->
assertTrue
(
$result
instanceof
Doctrine_ORM_Collection
);
$this
->
assertTrue
(
$result
[
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
0
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
]
instanceof
Doctrine_ORM_Entity
);
$this
->
assertTrue
(
$result
[
1
]
instanceof
Doctrine_ORM_Entity
);
}
else
if
(
$hydrationMode
==
Doctrine
::
HYDRATE_SCALAR
)
{
}
else
if
(
$hydrationMode
==
Doctrine
_Query
::
HYDRATE_SCALAR
)
{
//...
//...
}
}
...
@@ -922,16 +922,16 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
...
@@ -922,16 +922,16 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
if
(
$name
==
'result1'
)
{
if
(
$name
==
'result1'
)
{
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$stmt
,
$queryComponents
,
$tableAliasMap
,
Doctrine
::
HYDRATE_SINGLE_SCALAR
));
$stmt
,
$queryComponents
,
$tableAliasMap
,
Doctrine
_Query
::
HYDRATE_SINGLE_SCALAR
));
$this
->
assertEquals
(
'romanb'
,
$result
);
$this
->
assertEquals
(
'romanb'
,
$result
);
}
else
if
(
$name
==
'result2'
)
{
}
else
if
(
$name
==
'result2'
)
{
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$stmt
,
$queryComponents
,
$tableAliasMap
,
Doctrine
::
HYDRATE_SINGLE_SCALAR
));
$stmt
,
$queryComponents
,
$tableAliasMap
,
Doctrine
_Query
::
HYDRATE_SINGLE_SCALAR
));
$this
->
assertEquals
(
1
,
$result
);
$this
->
assertEquals
(
1
,
$result
);
}
else
if
(
$name
==
'result3'
||
$name
==
'result4'
)
{
}
else
if
(
$name
==
'result3'
||
$name
==
'result4'
)
{
try
{
try
{
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$result
=
$hydrator
->
hydrateResultSet
(
$this
->
_createParserResult
(
$stmt
,
$queryComponents
,
$tableAliasMap
,
Doctrine
::
HYDRATE_SINGLE_SCALAR
));
$stmt
,
$queryComponents
,
$tableAliasMap
,
Doctrine
_Query
::
HYDRATE_SINGLE_SCALAR
));
$this
->
fail
();
$this
->
fail
();
}
catch
(
Doctrine_ORM_Exceptions_HydrationException
$ex
)
{}
}
catch
(
Doctrine_ORM_Exceptions_HydrationException
$ex
)
{}
}
}
...
...
tests/lib/DoctrineTestInit.php
View file @
580f21c4
...
@@ -2,10 +2,25 @@
...
@@ -2,10 +2,25 @@
require_once
'PHPUnit/Framework.php'
;
require_once
'PHPUnit/Framework.php'
;
require_once
'PHPUnit/TextUI/TestRunner.php'
;
require_once
'PHPUnit/TextUI/TestRunner.php'
;
require_once
'../lib/Doctrine.php'
;
//
require_once '../lib/Doctrine.php';
spl_autoload_register
(
array
(
'Doctrine'
,
'autoload'
))
;
require_once
'../lib/Doctrine/Common/ClassLoader.php'
;
// Some of these classes depends on Doctrine_* classes
$classLoader
=
new
Doctrine_Common_ClassLoader
();
// checking for existance should not be necessary, remove as soon as possible
$classLoader
->
setCheckFileExists
(
true
);
$classLoader
->
register
();
$modelDir
=
dirname
(
__FILE__
)
.
DIRECTORY_SEPARATOR
.
'..'
.
DIRECTORY_SEPARATOR
.
'models'
;
set_include_path
(
get_include_path
()
.
PATH_SEPARATOR
.
dirname
(
__FILE__
)
.
DIRECTORY_SEPARATOR
.
'..'
.
DIRECTORY_SEPARATOR
.
'..'
.
DIRECTORY_SEPARATOR
.
'lib'
.
PATH_SEPARATOR
.
$modelDir
.
DIRECTORY_SEPARATOR
.
'cms'
.
PATH_SEPARATOR
.
$modelDir
.
DIRECTORY_SEPARATOR
.
'company'
.
PATH_SEPARATOR
.
$modelDir
.
DIRECTORY_SEPARATOR
.
'ecommerce'
.
PATH_SEPARATOR
.
$modelDir
.
DIRECTORY_SEPARATOR
.
'forum'
);
// Some of these classes depend on Doctrine_* classes
require_once
'Doctrine_TestCase.php'
;
require_once
'Doctrine_TestCase.php'
;
require_once
'Doctrine_TestUtil.php'
;
require_once
'Doctrine_TestUtil.php'
;
require_once
'Doctrine_DbalTestCase.php'
;
require_once
'Doctrine_DbalTestCase.php'
;
...
@@ -15,22 +30,3 @@ require_once 'Doctrine_TestSuite.php';
...
@@ -15,22 +30,3 @@ require_once 'Doctrine_TestSuite.php';
require_once
'Doctrine_OrmTestSuite.php'
;
require_once
'Doctrine_OrmTestSuite.php'
;
require_once
'Doctrine_OrmFunctionalTestSuite.php'
;
require_once
'Doctrine_OrmFunctionalTestSuite.php'
;
require_once
'Doctrine_DbalTestSuite.php'
;
require_once
'Doctrine_DbalTestSuite.php'
;
$modelDir
=
dirname
(
__FILE__
)
.
DIRECTORY_SEPARATOR
.
'..'
.
DIRECTORY_SEPARATOR
.
'models'
;
Doctrine_Manager
::
getInstance
()
->
setAttribute
(
Doctrine
::
ATTR_MODEL_LOADING
,
Doctrine
::
MODEL_LOADING_CONSERVATIVE
);
Doctrine
::
loadModels
(
$modelDir
);
/*
//spl_autoload_register(array('Doctrine_TestUtil', 'autoload'));
$modelDir = dirname(__FILE__)
. DIRECTORY_SEPARATOR . '..'
. DIRECTORY_SEPARATOR . 'models'
. DIRECTORY_SEPARATOR;
set_include_path(
get_include_path()
. PATH_SEPARATOR . $modelDir . 'cms'
. PATH_SEPARATOR . $modelDir . 'ecommerce'
. PATH_SEPARATOR . $modelDir . 'forum');
*/
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment