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
71d1150e
Commit
71d1150e
authored
17 years ago
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Second merge from experimental branch to trunk.
parent
e01809d1
Changes
29
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
767 additions
and
498 deletions
+767
-498
Collection.php
lib/Doctrine/Collection.php
+87
-58
Connection.php
lib/Doctrine/Connection.php
+22
-67
UnitOfWork.php
lib/Doctrine/Connection/UnitOfWork.php
+10
-11
Hydrator.php
lib/Doctrine/Hydrator.php
+10
-4
ArrayDriver.php
lib/Doctrine/Hydrator/ArrayDriver.php
+6
-0
RecordDriver.php
lib/Doctrine/Hydrator/RecordDriver.php
+40
-12
Manager.php
lib/Doctrine/Manager.php
+1
-1
Abstract.php
lib/Doctrine/Mapper/Abstract.php
+220
-82
Joined.php
lib/Doctrine/Mapper/Joined.php
+157
-44
SingleTable.php
lib/Doctrine/Mapper/SingleTable.php
+53
-5
TablePerClass.php
lib/Doctrine/Mapper/TablePerClass.php
+1
-1
Query.php
lib/Doctrine/Query.php
+34
-88
Abstract.php
lib/Doctrine/Query/Abstract.php
+10
-17
RawSql.php
lib/Doctrine/RawSql.php
+1
-1
Record.php
lib/Doctrine/Record.php
+17
-42
Association.php
lib/Doctrine/Relation/Association.php
+3
-0
Mysql.php
lib/Doctrine/Sequence/Mysql.php
+1
-3
Pgsql.php
lib/Doctrine/Sequence/Pgsql.php
+2
-1
Table.php
lib/Doctrine/Table.php
+7
-5
Factory.php
lib/Doctrine/Table/Factory.php
+4
-8
Repository.php
lib/Doctrine/Table/Repository.php
+2
-2
Transaction.php
lib/Doctrine/Transaction.php
+0
-5
NestedSet.php
lib/Doctrine/Tree/NestedSet.php
+0
-35
ConnectionTestCase.php
tests/ConnectionTestCase.php
+3
-3
JoinedTestCase.php
tests/Inheritance/JoinedTestCase.php
+43
-1
SingleTableTestCase.php
tests/Inheritance/SingleTableTestCase.php
+10
-0
JoinCondition2TestCase.php
tests/Query/JoinCondition2TestCase.php
+1
-1
MultiJoin2TestCase.php
tests/Query/MultiJoin2TestCase.php
+1
-1
QueryTestCase.php
tests/QueryTestCase.php
+21
-0
No files found.
lib/Doctrine/Collection.php
View file @
71d1150e
This diff is collapsed.
Click to expand it.
lib/Doctrine/Connection.php
View file @
71d1150e
...
@@ -60,6 +60,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -60,6 +60,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*/
*/
protected
$dbh
;
protected
$dbh
;
/**
*
*/
protected
$_tableFactory
;
protected
$_tableFactory
;
/**
/**
...
@@ -169,6 +172,12 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -169,6 +172,12 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
'Sqlite'
,
'Sqlite'
,
'Firebird'
'Firebird'
);
);
/**
* The query count. Represents the number of executed database queries by the connection.
*
* @var integer
*/
protected
$_count
=
0
;
protected
$_count
=
0
;
/**
/**
...
@@ -184,9 +193,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -184,9 +193,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
throw
new
Doctrine_Connection_Exception
(
'First argument should be an instance of PDO or implement Doctrine_Adapter_Interface'
);
throw
new
Doctrine_Connection_Exception
(
'First argument should be an instance of PDO or implement Doctrine_Adapter_Interface'
);
}
}
$this
->
dbh
=
$adapter
;
$this
->
dbh
=
$adapter
;
$this
->
isConnected
=
true
;
$this
->
isConnected
=
true
;
}
else
if
(
is_array
(
$adapter
))
{
}
else
if
(
is_array
(
$adapter
))
{
$this
->
pendingAttributes
[
Doctrine
::
ATTR_DRIVER_NAME
]
=
$adapter
[
'scheme'
];
$this
->
pendingAttributes
[
Doctrine
::
ATTR_DRIVER_NAME
]
=
$adapter
[
'scheme'
];
...
@@ -235,7 +242,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -235,7 +242,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*/
*/
public
function
getAttribute
(
$attribute
)
public
function
getAttribute
(
$attribute
)
{
{
if
(
$attribute
>=
100
)
{
if
(
$attribute
>=
100
)
{
if
(
!
isset
(
$this
->
attributes
[
$attribute
]))
{
if
(
!
isset
(
$this
->
attributes
[
$attribute
]))
{
return
parent
::
getAttribute
(
$attribute
);
return
parent
::
getAttribute
(
$attribute
);
...
@@ -353,14 +359,13 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -353,14 +359,13 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
}
}
/**
/**
* returns the database handler
of
which this connection uses
* returns the database handler which this connection uses
*
*
* @return PDO the database handler
* @return PDO the database handler
*/
*/
public
function
getDbh
()
public
function
getDbh
()
{
{
$this
->
connect
();
$this
->
connect
();
return
$this
->
dbh
;
return
$this
->
dbh
;
}
}
...
@@ -372,13 +377,11 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -372,13 +377,11 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*/
*/
public
function
connect
()
public
function
connect
()
{
{
if
(
$this
->
isConnected
)
{
if
(
$this
->
isConnected
)
{
return
false
;
return
false
;
}
}
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
CONN_CONNECT
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
CONN_CONNECT
);
$this
->
getListener
()
->
preConnect
(
$event
);
$this
->
getListener
()
->
preConnect
(
$event
);
$e
=
explode
(
':'
,
$this
->
options
[
'dsn'
]);
$e
=
explode
(
':'
,
$this
->
options
[
'dsn'
]);
...
@@ -515,21 +518,19 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -515,21 +518,19 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*
*
* @throws Doctrine_Connection_Exception if something went wrong at the database level
* @throws Doctrine_Connection_Exception if something went wrong at the database level
* @param string $table The table to delete data from
* @param string $table The table to delete data from
* @param array $identifier An associateve array containing identifier
column
-value pairs.
* @param array $identifier An associateve array containing identifier
fieldname
-value pairs.
* @return integer The number of affected rows
* @return integer The number of affected rows
*/
*/
public
function
delete
(
Doctrine_Table
$table
,
array
$identifier
)
public
function
delete
(
Doctrine_Table
$table
,
array
$identifier
)
{
{
$tmp
=
array
();
$criteria
=
array
();
foreach
(
array_keys
(
$identifier
)
as
$id
)
{
foreach
(
array_keys
(
$identifier
)
as
$id
)
{
$
tmp
[]
=
$table
->
getColumnName
(
$id
)
.
' = ?'
;
$
criteria
[]
=
$table
->
getColumnName
(
$id
)
.
' = ?'
;
}
}
$query
=
'DELETE FROM '
$query
=
'DELETE FROM '
.
$this
->
quoteIdentifier
(
$table
->
getTableName
())
.
$this
->
quoteIdentifier
(
$table
->
getTableName
())
.
' WHERE '
.
implode
(
' AND '
,
$tmp
);
.
' WHERE '
.
implode
(
' AND '
,
$criteria
);
return
$this
->
exec
(
$query
,
array_values
(
$identifier
));
return
$this
->
exec
(
$query
,
array_values
(
$identifier
));
}
}
...
@@ -573,7 +574,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -573,7 +574,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* Inserts a table row with specified data.
* Inserts a table row with specified data.
*
*
* @param string $table The table to insert data into.
* @param string $table The table to insert data into.
* @param array $
values An associateve array containing column
-value pairs.
* @param array $
fields An associateve array containing fieldname
-value pairs.
* @return mixed boolean false if empty value array was given,
* @return mixed boolean false if empty value array was given,
* otherwise returns the number of affected rows
* otherwise returns the number of affected rows
*/
*/
...
@@ -606,53 +607,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -606,53 +607,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$query
.=
implode
(
', '
,
$a
)
.
')'
;
$query
.=
implode
(
', '
,
$a
)
.
')'
;
// prepare and execute the statement
// prepare and execute the statement
return
$this
->
exec
(
$query
,
array_values
(
$fields
));
}
/**
* @todo DESCRIBE WHAT THIS METHOD DOES, PLEASE!
*/
public
function
processSingleInsert
(
Doctrine_Record
$record
)
{
$fields
=
$record
->
getPrepared
();
if
(
empty
(
$fields
))
{
return
false
;
}
$table
=
$record
->
getTable
();
$identifier
=
(
array
)
$table
->
getIdentifier
();
$seq
=
$record
->
getTable
()
->
getOption
(
'sequenceName'
);
if
(
!
empty
(
$seq
))
{
$id
=
$this
->
sequence
->
nextId
(
$seq
);
$seqName
=
$table
->
getIdentifier
();
$fields
[
$seqName
]
=
$id
;
$record
->
assignIdentifier
(
$id
);
}
$this
->
insert
(
$table
,
$fields
);
if
(
empty
(
$seq
)
&&
count
(
$identifier
)
==
1
&&
$identifier
[
0
]
==
$table
->
getIdentifier
()
&&
$table
->
getIdentifierType
()
!=
Doctrine
::
IDENTIFIER_NATURAL
)
{
if
(
strtolower
(
$this
->
getName
())
==
'pgsql'
)
{
$seq
=
$table
->
getTableName
()
.
'_'
.
$identifier
[
0
];
}
$id
=
$this
->
sequence
->
lastInsertId
(
$seq
);
return
$this
->
exec
(
$query
,
array_values
(
$fields
));
}
if
(
!
$id
)
{
throw
new
Doctrine_Connection_Exception
(
"Couldn't get last insert identifier."
);
}
$record
->
assignIdentifier
(
$id
);
}
else
{
$record
->
assignIdentifier
(
true
);
}
}
/**
/**
* Set the charset on the current connection
* Set the charset on the current connection
...
@@ -661,11 +618,11 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -661,11 +618,11 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*/
*/
public
function
setCharset
(
$charset
)
public
function
setCharset
(
$charset
)
{
{
return
true
;
}
}
/**
/**
* Quote a string so it can be safely used as a table or column name
* Quote a string so it can be safely used as a table or column name
.
*
*
* Delimiting style depends on which database driver is being used.
* Delimiting style depends on which database driver is being used.
*
*
...
@@ -1032,7 +989,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -1032,7 +989,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
public
function
rethrowException
(
Exception
$e
,
$invoker
)
public
function
rethrowException
(
Exception
$e
,
$invoker
)
{
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
CONN_ERROR
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
CONN_ERROR
);
$this
->
getListener
()
->
preError
(
$event
);
$this
->
getListener
()
->
preError
(
$event
);
$name
=
'Doctrine_Connection_'
.
$this
->
driverName
.
'_Exception'
;
$name
=
'Doctrine_Connection_'
.
$this
->
driverName
.
'_Exception'
;
...
@@ -1079,7 +1035,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -1079,7 +1035,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
}
}
/**
/**
* Gets a mapper for the specified domain class that is used map instances of
* Gets a mapper for the specified domain class that is used
to
map instances of
* the class between the relational database and their object representation.
* the class between the relational database and their object representation.
*
*
* @return Doctrine_Mapper_Abstract The mapper object.
* @return Doctrine_Mapper_Abstract The mapper object.
...
@@ -1092,9 +1048,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -1092,9 +1048,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$customMapperClass
=
$className
.
'Mapper'
;
$customMapperClass
=
$className
.
'Mapper'
;
if
(
class_exists
(
$customMapperClass
,
$this
->
getAttribute
(
Doctrine
::
ATTR_AUTOLOAD_TABLE_CLASSES
))
&&
if
(
class_exists
(
$customMapperClass
,
$this
->
getAttribute
(
Doctrine
::
ATTR_AUTOLOAD_TABLE_CLASSES
))
&&
in_array
(
'Doctrine_Mapper'
,
class_parents
(
$customMapperClass
)))
{
in_array
(
'Doctrine_Mapper
_Abstract
'
,
class_parents
(
$customMapperClass
)))
{
$table
=
$this
->
getTable
(
$className
);
$table
=
$this
->
getTable
(
$className
);
$mapper
=
new
$customMapperClass
(
$className
,
$t
his
);
$mapper
=
new
$customMapperClass
(
$className
,
$t
able
);
}
else
{
}
else
{
// instantiate correct mapper type
// instantiate correct mapper type
$table
=
$this
->
getTable
(
$className
);
$table
=
$this
->
getTable
(
$className
);
...
@@ -1250,7 +1206,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -1250,7 +1206,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
public
function
close
()
public
function
close
()
{
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
CONN_CLOSE
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
CONN_CLOSE
);
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
preClose
(
$event
);
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
preClose
(
$event
);
$this
->
clear
();
$this
->
clear
();
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Connection/UnitOfWork.php
View file @
71d1150e
...
@@ -73,7 +73,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -73,7 +73,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
{
{
$tree
=
array
();
$tree
=
array
();
foreach
(
$tables
as
$k
=>
$table
)
{
foreach
(
$tables
as
$k
=>
$table
)
{
if
(
!
(
$table
instanceof
Doctrine_Mapper
))
{
if
(
!
(
$table
instanceof
Doctrine_Mapper
_Abstract
))
{
$table
=
$this
->
conn
->
getMapper
(
$table
);
$table
=
$this
->
conn
->
getMapper
(
$table
);
}
}
$nm
=
$table
->
getComponentName
();
$nm
=
$table
->
getComponentName
();
...
@@ -281,7 +281,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -281,7 +281,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
* @return boolean true on success, false on failure
* @return boolean true on success, false on failure
* @todo Move to Doctrine_Table (which will become Doctrine_Mapper).
* @todo Move to Doctrine_Table (which will become Doctrine_Mapper).
*/
*/
public
function
delete
(
Doctrine_Record
$record
)
/*
public function delete(Doctrine_Record $record)
{
{
if ( ! $this->_autoflush) {
if ( ! $this->_autoflush) {
return true;
return true;
...
@@ -331,7 +331,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -331,7 +331,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
$this->conn->commit();
$this->conn->commit();
return true;
return true;
}
}
*/
/**
/**
* @todo Description. See also the todo for deleteMultiple().
* @todo Description. See also the todo for deleteMultiple().
...
@@ -356,6 +356,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -356,6 +356,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
}*/
}*/
/**
/**
* DOESNT SEEM TO BE USED ANYWHERE.
*
* deleteMultiple
* deleteMultiple
* deletes all records from the pending delete list
* deletes all records from the pending delete list
*
*
...
@@ -364,7 +366,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -364,7 +366,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
* queries itself and sometimes it leaves the sql construction to Connection.
* queries itself and sometimes it leaves the sql construction to Connection.
* This should be changed.
* This should be changed.
*/
*/
public
function
deleteMultiple
(
array
$records
)
/*
public function deleteMultiple(array $records)
{
{
foreach ($this->delete as $name => $deletes) {
foreach ($this->delete as $name => $deletes) {
$record = false;
$record = false;
...
@@ -414,7 +416,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -414,7 +416,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
}
}
}
}
}
}
}
}
*/
/**
/**
* saveRelated
* saveRelated
...
@@ -498,7 +500,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -498,7 +500,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
* @throws PDOException if something went wrong at database level
* @throws PDOException if something went wrong at database level
* @return void
* @return void
*/
*/
public
function
deleteComposites
(
Doctrine_Record
$record
)
/*
public function deleteComposites(Doctrine_Record $record)
{
{
foreach ($record->getTable()->getRelations() as $fk) {
foreach ($record->getTable()->getRelations() as $fk) {
if ($fk->isComposite()) {
if ($fk->isComposite()) {
...
@@ -509,7 +511,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -509,7 +511,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
}
}
}
}
}
}
}
}
*/
/**
/**
* saveAll
* saveAll
...
@@ -554,22 +556,19 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -554,22 +556,19 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
//echo "<br /><br />flushin all.<br /><br />";
//echo "<br /><br />flushin all.<br /><br />";
// get the flush tree
// get the flush tree
$tree
=
$this
->
buildFlushTree
(
$this
->
conn
->
getMappers
());
$tree
=
$this
->
buildFlushTree
(
$this
->
conn
->
getMappers
());
//foreach ($tree as $name) echo $name . "<br />";
// save all records
// save all records
foreach
(
$tree
as
$name
)
{
foreach
(
$tree
as
$name
)
{
$mapper
=
$this
->
conn
->
getMapper
(
$name
);
$mapper
=
$this
->
conn
->
getMapper
(
$name
);
foreach
(
$mapper
->
getRepository
()
as
$record
)
{
foreach
(
$mapper
->
getRepository
()
as
$record
)
{
//echo $record->getOid() . "<br />";
//echo $record->getOid() . "<br />";
$mapper
->
save
(
$record
);
$mapper
->
save
SingleRecord
(
$record
);
}
}
}
}
// save all associations
// save all associations
foreach
(
$tree
as
$name
)
{
foreach
(
$tree
as
$name
)
{
$mapper
=
$this
->
conn
->
getMapper
(
$name
);
$mapper
=
$this
->
conn
->
getMapper
(
$name
);
foreach
(
$mapper
->
getRepository
()
as
$record
)
{
foreach
(
$mapper
->
getRepository
()
as
$record
)
{
$mapper
->
saveAssociations
(
$record
);
$mapper
->
saveAssociations
(
$record
);
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Hydrator.php
View file @
71d1150e
...
@@ -106,6 +106,7 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
...
@@ -106,6 +106,7 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
// Initialize
// Initialize
foreach
(
$this
->
_queryComponents
as
$dqlAlias
=>
$data
)
{
foreach
(
$this
->
_queryComponents
as
$dqlAlias
=>
$data
)
{
$data
[
'mapper'
]
->
setAttribute
(
Doctrine
::
ATTR_LOAD_REFERENCES
,
false
);
$componentName
=
$data
[
'mapper'
]
->
getComponentName
();
$componentName
=
$data
[
'mapper'
]
->
getComponentName
();
$listeners
[
$componentName
]
=
$data
[
'table'
]
->
getRecordListener
();
$listeners
[
$componentName
]
=
$data
[
'table'
]
->
getRecordListener
();
$identifierMap
[
$dqlAlias
]
=
array
();
$identifierMap
[
$dqlAlias
]
=
array
();
...
@@ -229,6 +230,11 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
...
@@ -229,6 +230,11 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
$driver
->
flush
();
$driver
->
flush
();
// re-enable lazy loading
foreach
(
$this
->
_queryComponents
as
$dqlAlias
=>
$data
)
{
$data
[
'mapper'
]
->
setAttribute
(
Doctrine
::
ATTR_LOAD_REFERENCES
,
true
);
}
//$e = microtime(true);
//$e = microtime(true);
//echo 'Hydration took: ' . ($e - $s) . ' for '.count($result).' records<br />';
//echo 'Hydration took: ' . ($e - $s) . ' for '.count($result).' records<br />';
...
@@ -290,8 +296,9 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
...
@@ -290,8 +296,9 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
$e
=
explode
(
'__'
,
$key
);
$e
=
explode
(
'__'
,
$key
);
$last
=
strtolower
(
array_pop
(
$e
));
$last
=
strtolower
(
array_pop
(
$e
));
$cache
[
$key
][
'dqlAlias'
]
=
$this
->
_tableAliases
[
strtolower
(
implode
(
'__'
,
$e
))];
$cache
[
$key
][
'dqlAlias'
]
=
$this
->
_tableAliases
[
strtolower
(
implode
(
'__'
,
$e
))];
$table
=
$this
->
_queryComponents
[
$cache
[
$key
][
'dqlAlias'
]][
'table'
];
$mapper
=
$this
->
_queryComponents
[
$cache
[
$key
][
'dqlAlias'
]][
'mapper'
];
$fieldName
=
$table
->
getFieldName
(
$last
);
$table
=
$mapper
->
getTable
();
$fieldName
=
$mapper
->
getFieldName
(
$last
);
$cache
[
$key
][
'fieldName'
]
=
$fieldName
;
$cache
[
$key
][
'fieldName'
]
=
$fieldName
;
if
(
$table
->
isIdentifier
(
$fieldName
))
{
if
(
$table
->
isIdentifier
(
$fieldName
))
{
$cache
[
$key
][
'isIdentifier'
]
=
true
;
$cache
[
$key
][
'isIdentifier'
]
=
true
;
...
@@ -306,8 +313,7 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
...
@@ -306,8 +313,7 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
}
}
}
}
$map
=
$this
->
_queryComponents
[
$cache
[
$key
][
'dqlAlias'
]];
$mapper
=
$this
->
_queryComponents
[
$cache
[
$key
][
'dqlAlias'
]][
'mapper'
];
$mapper
=
$map
[
'mapper'
];
$dqlAlias
=
$cache
[
$key
][
'dqlAlias'
];
$dqlAlias
=
$cache
[
$key
][
'dqlAlias'
];
$fieldName
=
$cache
[
$key
][
'fieldName'
];
$fieldName
=
$cache
[
$key
][
'fieldName'
];
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Hydrator/ArrayDriver.php
View file @
71d1150e
...
@@ -37,18 +37,22 @@ class Doctrine_Hydrator_ArrayDriver
...
@@ -37,18 +37,22 @@ class Doctrine_Hydrator_ArrayDriver
{
{
return
array
();
return
array
();
}
}
public
function
getElement
(
array
$data
,
$component
)
public
function
getElement
(
array
$data
,
$component
)
{
{
return
$data
;
return
$data
;
}
}
public
function
isIdentifiable
(
array
$data
,
Doctrine_Table
$table
)
public
function
isIdentifiable
(
array
$data
,
Doctrine_Table
$table
)
{
{
return
(
!
empty
(
$data
));
return
(
!
empty
(
$data
));
}
}
public
function
registerCollection
(
$coll
)
public
function
registerCollection
(
$coll
)
{
{
}
}
public
function
initRelated
(
array
&
$data
,
$name
)
public
function
initRelated
(
array
&
$data
,
$name
)
{
{
if
(
!
isset
(
$data
[
$name
]))
{
if
(
!
isset
(
$data
[
$name
]))
{
...
@@ -56,10 +60,12 @@ class Doctrine_Hydrator_ArrayDriver
...
@@ -56,10 +60,12 @@ class Doctrine_Hydrator_ArrayDriver
}
}
return
true
;
return
true
;
}
}
public
function
getNullPointer
()
public
function
getNullPointer
()
{
{
return
null
;
return
null
;
}
}
public
function
getLastKey
(
&
$data
)
public
function
getLastKey
(
&
$data
)
{
{
end
(
$data
);
end
(
$data
);
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Hydrator/RecordDriver.php
View file @
71d1150e
...
@@ -20,8 +20,8 @@
...
@@ -20,8 +20,8 @@
*/
*/
/**
/**
* Doctrine_Hydrate_Record
* Doctrine_Hydrate_Record
Driver
*
defines a record fetching strategy for Doctrine_Hydrate
*
Hydration strategy used for creating collections of entity objects.
*
*
* @package Doctrine
* @package Doctrine
* @subpackage Hydrate
* @subpackage Hydrate
...
@@ -30,14 +30,13 @@
...
@@ -30,14 +30,13 @@
* @since 1.0
* @since 1.0
* @version $Revision$
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
Doctrine_Hydrator_RecordDriver
extends
Doctrine_Locator_Injectable
class
Doctrine_Hydrator_RecordDriver
extends
Doctrine_Locator_Injectable
{
{
protected
$_collections
=
array
();
protected
$_collections
=
array
();
protected
$_records
=
array
();
protected
$_records
=
array
();
protected
$_mappers
=
array
();
protected
$_tables
=
array
();
public
function
getElementCollection
(
$component
)
public
function
getElementCollection
(
$component
)
{
{
...
@@ -105,13 +104,12 @@ class Doctrine_Hydrator_RecordDriver extends Doctrine_Locator_Injectable
...
@@ -105,13 +104,12 @@ class Doctrine_Hydrator_RecordDriver extends Doctrine_Locator_Injectable
public
function
getElement
(
array
$data
,
$component
)
public
function
getElement
(
array
$data
,
$component
)
{
{
if
(
!
isset
(
$this
->
_tables
[
$component
]))
{
if
(
!
isset
(
$this
->
_mappers
[
$component
]))
{
$this
->
_tables
[
$component
]
=
Doctrine_Manager
::
getInstance
()
->
getMapper
(
$component
);
$this
->
_mappers
[
$component
]
=
Doctrine_Manager
::
getInstance
()
->
getMapper
(
$component
);
$this
->
_tables
[
$component
]
->
setAttribute
(
Doctrine
::
ATTR_LOAD_REFERENCES
,
false
);
}
}
$
this
->
_tables
[
$component
]
->
setData
(
$data
);
$
component
=
$this
->
_getClassnameToReturn
(
$data
,
$component
);
$record
=
$this
->
_
tables
[
$component
]
->
getRecord
(
);
$record
=
$this
->
_
mappers
[
$component
]
->
getRecord
(
$data
);
if
(
!
isset
(
$this
->
_records
[
$record
->
getOid
()])
)
{
if
(
!
isset
(
$this
->
_records
[
$record
->
getOid
()])
)
{
$record
->
clearRelated
();
$record
->
clearRelated
();
...
@@ -127,8 +125,38 @@ class Doctrine_Hydrator_RecordDriver extends Doctrine_Locator_Injectable
...
@@ -127,8 +125,38 @@ class Doctrine_Hydrator_RecordDriver extends Doctrine_Locator_Injectable
foreach
(
$this
->
_collections
as
$key
=>
$coll
)
{
foreach
(
$this
->
_collections
as
$key
=>
$coll
)
{
$coll
->
takeSnapshot
();
$coll
->
takeSnapshot
();
}
}
foreach
(
$this
->
_tables
as
$table
)
{
}
$table
->
setAttribute
(
Doctrine
::
ATTR_LOAD_REFERENCES
,
true
);
/**
* Check the dataset for a discriminator column, to determine the correct
* class to instantiate. If no discriminator column is found, the given
* classname will be returned.
*
* @todo this function could use reflection to check the first time it runs
* if the subclassing option is not set.
*
* @return string The name of the class to instantiate.
*
*/
protected
function
_getClassnameToReturn
(
array
$data
,
$className
)
{
$subClasses
=
$this
->
_mappers
[
$className
]
->
getTable
()
->
getOption
(
'subclasses'
);
if
(
!
isset
(
$subClasses
))
{
return
$className
;
}
foreach
(
$subClasses
as
$subclass
)
{
if
(
!
isset
(
$this
->
_mappers
[
$subclass
]))
{
$this
->
_mappers
[
$subclass
]
=
Doctrine_Manager
::
getInstance
()
->
getMapper
(
$subclass
);
}
$mapper
=
$this
->
_mappers
[
$subclass
];
$inheritanceMap
=
$mapper
->
getDiscriminatorColumn
();
foreach
(
$inheritanceMap
as
$key
=>
$value
)
{
if
(
isset
(
$data
[
$key
])
&&
$data
[
$key
]
==
$value
)
{
return
$mapper
->
getComponentName
();
}
}
}
}
return
$className
;
}
}
}
}
This diff is collapsed.
Click to expand it.
lib/Doctrine/Manager.php
View file @
71d1150e
...
@@ -255,7 +255,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
...
@@ -255,7 +255,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
}
}
$driverName
=
$adapter
->
getAttribute
(
Doctrine
::
ATTR_DRIVER_NAME
);
$driverName
=
$adapter
->
getAttribute
(
Doctrine
::
ATTR_DRIVER_NAME
);
}
elseif
(
is_array
(
$adapter
))
{
}
else
if
(
is_array
(
$adapter
))
{
if
(
!
isset
(
$adapter
[
0
]))
{
if
(
!
isset
(
$adapter
[
0
]))
{
throw
new
Doctrine_Manager_Exception
(
'Empty data source name given.'
);
throw
new
Doctrine_Manager_Exception
(
'Empty data source name given.'
);
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Mapper.php
→
lib/Doctrine/Mapper
/Abstract
.php
View file @
71d1150e
This diff is collapsed.
Click to expand it.
lib/Doctrine/Mapper/Joined.php
View file @
71d1150e
This diff is collapsed.
Click to expand it.
lib/Doctrine/Mapper/SingleTable.php
View file @
71d1150e
<?php
<?php
class
Doctrine_Mapper_SingleTable
extends
Doctrine_Mapper
class
Doctrine_Mapper_SingleTable
extends
Doctrine_Mapper
_Abstract
{
{
public
function
getDiscriminatorColumn
(
$domainClassName
)
public
function
getDiscriminatorColumn
()
{
{
$inheritanceMap
=
$this
->
_table
->
getOption
(
'inheritanceMap'
);
$inheritanceMap
=
$this
->
_table
->
getOption
(
'inheritanceMap'
);
return
isset
(
$inheritanceMap
[
$
domainClassName
])
?
$inheritanceMap
[
$
domainClassName
]
:
array
();
return
isset
(
$inheritanceMap
[
$
this
->
_domainClassName
])
?
$inheritanceMap
[
$this
->
_
domainClassName
]
:
array
();
}
}
/*public function addToWhere($componentAlias, array &$sqlWhereParts, Doctrine_Query $query)
{
$array = array();
$componentParts = $query->getQueryComponent($componentAlias);
$sqlTableAlias = $query->getSqlTableAlias($componentAlias);
$array[$sqlTableAlias][] = $this->getDiscriminatorColumn();
// apply inheritance maps
$str = '';
$c = array();
$index = 0;
foreach ($array as $tableAlias => $maps) {
$a = array();
// don't use table aliases if the query isn't a select query
if ($query->getType() !== Doctrine_Query::SELECT) {
$tableAlias = '';
} else {
$tableAlias .= '.';
}
foreach ($maps as $map) {
$b = array();
foreach ($map as $field => $value) {
$identifier = $this->_conn->quoteIdentifier($tableAlias . $field);
if ($index > 0) {
$b[] = '(' . $identifier . ' = ' . $this->_conn->quote($value)
. ' OR ' . $identifier . ' IS NULL)';
} else {
$b[] = $identifier . ' = ' . $this->_conn->quote($value);
}
}
if ( ! empty($b)) {
$a[] = implode(' AND ', $b);
}
}
if ( ! empty($a)) {
$c[] = implode(' AND ', $a);
}
$index++;
}
$str .= implode(' AND ', $c);
return $str;
}*/
}
}
This diff is collapsed.
Click to expand it.
lib/Doctrine/Mapper/TablePerClass.php
View file @
71d1150e
<?php
<?php
class
Doctrine_Mapper_TablePerClass
extends
Doctrine_Mapper
class
Doctrine_Mapper_TablePerClass
extends
Doctrine_Mapper
_Abstract
{
{
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Query.php
View file @
71d1150e
This diff is collapsed.
Click to expand it.
lib/Doctrine/Query/Abstract.php
View file @
71d1150e
...
@@ -532,11 +532,11 @@ abstract class Doctrine_Query_Abstract
...
@@ -532,11 +532,11 @@ abstract class Doctrine_Query_Abstract
$tableAlias
=
$this
->
getSqlTableAlias
(
$componentAlias
,
$table
->
getTableName
());
$tableAlias
=
$this
->
getSqlTableAlias
(
$componentAlias
,
$table
->
getTableName
());
$customJoins
=
$this
->
_conn
->
getMapper
(
$componentName
)
->
getCustomJoins
();
$customJoins
=
$this
->
_conn
->
getMapper
(
$componentName
)
->
getCustomJoins
();
$sql
=
''
;
$sql
=
''
;
foreach
(
$customJoins
as
$componentName
)
{
foreach
(
$customJoins
as
$componentName
=>
$joinType
)
{
$joinedTable
=
$this
->
_conn
->
getTable
(
$componentName
);
$joinedTable
=
$this
->
_conn
->
getTable
(
$componentName
);
$joinedAlias
=
$componentAlias
.
'.'
.
$componentName
;
$joinedAlias
=
$componentAlias
.
'.'
.
$componentName
;
$joinedTableAlias
=
$this
->
getSqlTableAlias
(
$joinedAlias
,
$joinedTable
->
getTableName
());
$joinedTableAlias
=
$this
->
getSqlTableAlias
(
$joinedAlias
,
$joinedTable
->
getTableName
());
$sql
.=
' LEFT JOIN '
.
$this
->
_conn
->
quoteIdentifier
(
$joinedTable
->
getTableName
())
$sql
.=
"
$joinType
JOIN "
.
$this
->
_conn
->
quoteIdentifier
(
$joinedTable
->
getTableName
())
.
' '
.
$this
->
_conn
->
quoteIdentifier
(
$joinedTableAlias
)
.
' ON '
;
.
' '
.
$this
->
_conn
->
quoteIdentifier
(
$joinedTableAlias
)
.
' ON '
;
foreach
(
$table
->
getIdentifierColumnNames
()
as
$column
)
{
foreach
(
$table
->
getIdentifierColumnNames
()
as
$column
)
{
...
@@ -556,23 +556,16 @@ abstract class Doctrine_Query_Abstract
...
@@ -556,23 +556,16 @@ abstract class Doctrine_Query_Abstract
*
*
* @return string The created SQL snippet.
* @return string The created SQL snippet.
*/
*/
protected
function
_createDiscriminatorSql
()
protected
function
_createDiscriminator
Condition
Sql
()
{
{
$array
=
array
();
$array
=
array
();
foreach
(
$this
->
_queryComponents
as
$componentAlias
=>
$data
)
{
foreach
(
$this
->
_queryComponents
as
$componentAlias
=>
$data
)
{
$tableAlias
=
$this
->
getSqlTableAlias
(
$componentAlias
);
$sqlTableAlias
=
$this
->
getSqlTableAlias
(
$componentAlias
);
//echo $data['table']->getComponentName() . " -- ";
if
(
!
$data
[
'mapper'
]
instanceof
Doctrine_Mapper_SingleTable
)
{
/*if (!isset($data['mapper'])) {
$array
[
$sqlTableAlias
][]
=
array
();
//echo $data['table']->getComponentName();
}
else
{
echo $this->getDql();
$array
[
$sqlTableAlias
][]
=
$data
[
'mapper'
]
->
getDiscriminatorColumn
();
}*/
}
/*if ($data['mapper']->getComponentName() != $data['table']->getComponentName()) {
//echo $this->getDql() . "<br />";
}*/
//echo $data['mapper']->getComponentName() . "_<br />";
//var_dump($data['mapper']->getDiscriminatorColumn($data['mapper']->getComponentName()));
$array
[
$tableAlias
][]
=
$data
[
'mapper'
]
->
getDiscriminatorColumn
(
$data
[
'mapper'
]
->
getComponentName
());
}
}
//var_dump($array);
//var_dump($array);
// apply inheritance maps
// apply inheritance maps
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/RawSql.php
View file @
71d1150e
...
@@ -238,7 +238,7 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
...
@@ -238,7 +238,7 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
}
}
}
}
$string
=
$this
->
_createDiscriminatorSql
();
$string
=
$this
->
_createDiscriminator
Condition
Sql
();
if
(
!
empty
(
$string
))
{
if
(
!
empty
(
$string
))
{
$this
->
_sqlParts
[
'where'
][]
=
$string
;
$this
->
_sqlParts
[
'where'
][]
=
$string
;
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Record.php
View file @
71d1150e
...
@@ -146,7 +146,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -146,7 +146,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
* open connections
* open connections
* @throws Doctrine_Record_Exception if the cleanData operation fails somehow
* @throws Doctrine_Record_Exception if the cleanData operation fails somehow
*/
*/
public
function
__construct
(
$mapper
=
null
,
$isNewEntry
=
false
)
public
function
__construct
(
$mapper
=
null
,
$isNewEntry
=
false
,
array
$data
=
array
()
)
{
{
//echo get_class($this) . "<br />";
//echo get_class($this) . "<br />";
if
(
isset
(
$mapper
)
&&
$mapper
instanceof
Doctrine_Table
)
{
if
(
isset
(
$mapper
)
&&
$mapper
instanceof
Doctrine_Table
)
{
...
@@ -155,18 +155,10 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -155,18 +155,10 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
//$this->_mapper = Doctrine_Manager::getInstance()->getMapper(get_class($this));
//$this->_mapper = Doctrine_Manager::getInstance()->getMapper(get_class($this));
$exists
=
!
$isNewEntry
;
$exists
=
!
$isNewEntry
;
return
;
return
;
}
else
if
(
isset
(
$mapper
)
&&
$mapper
instanceof
Doctrine_Mapper
)
{
}
else
if
(
isset
(
$mapper
)
&&
$mapper
instanceof
Doctrine_Mapper
_Abstract
)
{
//echo "two<br />";
//echo "two<br />";
$class
=
get_class
(
$this
);
$class
=
get_class
(
$this
);
$this
->
_mapper
=
Doctrine_Manager
::
getInstance
()
->
getMapper
(
$class
);
$this
->
_mapper
=
Doctrine_Manager
::
getInstance
()
->
getMapper
(
$class
);
if
(
$class
!=
$this
->
_mapper
->
getComponentName
())
{
try
{
throw
new
Exception
(
"ddd"
);
}
catch
(
Exception
$e
)
{
echo
"MISMATCH: "
.
get_class
(
$this
)
.
"---"
.
$mapper
->
getComponentName
();
echo
$e
->
getTraceAsString
()
.
"<br /><br />"
;
}
}
$this
->
_table
=
$this
->
_mapper
->
getTable
();
$this
->
_table
=
$this
->
_mapper
->
getTable
();
$exists
=
!
$isNewEntry
;
$exists
=
!
$isNewEntry
;
}
else
{
}
else
{
...
@@ -182,7 +174,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -182,7 +174,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
self
::
$_index
++
;
self
::
$_index
++
;
// get the data array
// get the data array
$this
->
_data
=
$
this
->
_mapper
->
getData
()
;
$this
->
_data
=
$
data
;
// get the column count
// get the column count
$count
=
count
(
$this
->
_data
);
$count
=
count
(
$this
->
_data
);
...
@@ -202,7 +194,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -202,7 +194,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$this
->
assignDefaultValues
();
$this
->
assignDefaultValues
();
}
else
{
}
else
{
$this
->
_state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
_state
=
Doctrine_Record
::
STATE_CLEAN
;
// @TODO table->getColumnCount is not correct in CTI
if
(
$count
<
$this
->
_table
->
getColumnCount
())
{
if
(
$count
<
$this
->
_table
->
getColumnCount
())
{
$this
->
_state
=
Doctrine_Record
::
STATE_PROXY
;
$this
->
_state
=
Doctrine_Record
::
STATE_PROXY
;
}
}
...
@@ -213,7 +205,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -213,7 +205,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$repository
->
add
(
$this
);
$repository
->
add
(
$this
);
$this
->
construct
();
$this
->
construct
();
}
}
/**
/**
...
@@ -256,11 +247,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -256,11 +247,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
{
{
return
$this
->
_oid
;
return
$this
->
_oid
;
}
}
public
function
oid
()
{
return
$this
->
_oid
;
}
/**
/**
* isValid
* isValid
...
@@ -534,22 +520,22 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -534,22 +520,22 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
/**
/**
* serialize
* Serializes the entity.
* this method is automatically called when this Doctrine_Record is serialized
* This method is automatically called when the entity is serialized.
*
* Part of the implementation of the Serializable interface.
*
*
* @return array
* @return array
*/
*/
public
function
serialize
()
public
function
serialize
()
{
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
RECORD_SERIALIZE
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
RECORD_SERIALIZE
);
$this
->
preSerialize
(
$event
);
$this
->
preSerialize
(
$event
);
$vars
=
get_object_vars
(
$this
);
$vars
=
get_object_vars
(
$this
);
unset
(
$vars
[
'_references'
]);
unset
(
$vars
[
'_references'
]);
unset
(
$vars
[
'_mapper'
]);
unset
(
$vars
[
'_mapper'
]);
//unset($vars['_table']);
unset
(
$vars
[
'_errorStack'
]);
unset
(
$vars
[
'_errorStack'
]);
unset
(
$vars
[
'_filter'
]);
unset
(
$vars
[
'_filter'
]);
unset
(
$vars
[
'_node'
]);
unset
(
$vars
[
'_node'
]);
...
@@ -586,8 +572,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -586,8 +572,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
/**
/**
*
unseralize
*
Reconstructs the entity from it's serialized form.
*
this method is automatically called everytime a Doctrine_Record object is unserialized
*
This method is automatically called everytime the entity is unserialized.
*
*
* @param string $serialized Doctrine_Record as serialized string
* @param string $serialized Doctrine_Record as serialized string
* @throws Doctrine_Record_Exception if the cleanData operation fails somehow
* @throws Doctrine_Record_Exception if the cleanData operation fails somehow
...
@@ -634,6 +620,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -634,6 +620,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$this
->
_mapper
->
getRepository
()
->
add
(
$this
);
$this
->
_mapper
->
getRepository
()
->
add
(
$this
);
$this
->
cleanData
(
$this
->
_data
);
$this
->
cleanData
(
$this
->
_data
);
$this
->
prepareIdentifiers
(
$this
->
exists
());
$this
->
prepareIdentifiers
(
$this
->
exists
());
$this
->
postUnserialize
(
$event
);
$this
->
postUnserialize
(
$event
);
}
}
...
@@ -676,7 +663,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -676,7 +663,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
if
(
$err
)
{
if
(
$err
)
{
throw
new
Doctrine_Record_Exception
(
'Unknown record state '
.
$state
);
throw
new
Doctrine_Record_Exception
(
"Unknown record state '
$state
'."
);
}
}
}
}
...
@@ -863,12 +850,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -863,12 +850,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
if
(
!
isset
(
$this
->
_references
[
$fieldName
])
&&
$load
)
{
if
(
!
isset
(
$this
->
_references
[
$fieldName
])
&&
$load
)
{
$rel
=
$this
->
_table
->
getRelation
(
$fieldName
);
$rel
=
$this
->
_table
->
getRelation
(
$fieldName
);
$this
->
_references
[
$fieldName
]
=
$rel
->
fetchRelatedFor
(
$this
);
$this
->
_references
[
$fieldName
]
=
$rel
->
fetchRelatedFor
(
$this
);
/*if (count($this->_references[$fieldName]) > 0) {
echo $this->_references[$fieldName][0]->state() . "<br />";
}*/
}
}
return
$this
->
_references
[
$fieldName
];
return
$this
->
_references
[
$fieldName
];
}
catch
(
Doctrine_Table_Exception
$e
)
{
}
catch
(
Doctrine_Table_Exception
$e
)
{
//echo $e->getTraceAsString();
//echo $e->getTraceAsString();
//echo "<br /><br />";
//echo "<br /><br />";
...
@@ -937,12 +920,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -937,12 +920,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$this
->
_modified
[]
=
$fieldName
;
$this
->
_modified
[]
=
$fieldName
;
switch
(
$this
->
_state
)
{
switch
(
$this
->
_state
)
{
case
Doctrine_Record
::
STATE_CLEAN
:
case
Doctrine_Record
::
STATE_CLEAN
:
/*try {
throw new Exception();
} catch (Exception $e) {
echo $e->getTraceAsString() . "<br /><br />";
}
echo "setting dirty ... <br />";*/
$this
->
_state
=
Doctrine_Record
::
STATE_DIRTY
;
$this
->
_state
=
Doctrine_Record
::
STATE_DIRTY
;
break
;
break
;
case
Doctrine_Record
::
STATE_TCLEAN
:
case
Doctrine_Record
::
STATE_TCLEAN
:
...
@@ -1004,7 +981,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1004,7 +981,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
}
}
}
}
}
else
if
(
$rel
instanceof
Doctrine_Relation_Association
)
{
}
else
if
(
$rel
instanceof
Doctrine_Relation_Association
)
{
// join table relation found
// join table relation found
if
(
!
(
$value
instanceof
Doctrine_Collection
))
{
if
(
!
(
$value
instanceof
Doctrine_Collection
))
{
...
@@ -1070,7 +1046,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1070,7 +1046,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*/
*/
public
function
save
(
Doctrine_Connection
$conn
=
null
)
public
function
save
(
Doctrine_Connection
$conn
=
null
)
{
{
$this
->
_mapper
->
save
Graph
(
$this
,
$conn
);
$this
->
_mapper
->
save
(
$this
,
$conn
);
}
}
/**
/**
...
@@ -1209,7 +1185,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1209,7 +1185,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
}
}
//$map = $this->_table->getOption('inheritanceMap');
//$map = $this->_table->getOption('inheritanceMap');
$map
=
$this
->
_mapper
->
getDiscriminatorColumn
(
$this
->
_domainClassName
);
$map
=
$this
->
_mapper
->
getDiscriminatorColumn
();
foreach
(
$map
as
$k
=>
$v
)
{
foreach
(
$map
as
$k
=>
$v
)
{
$old
=
$this
->
get
(
$k
,
false
);
$old
=
$this
->
get
(
$k
,
false
);
if
((
string
)
$old
!==
(
string
)
$v
||
$old
===
null
)
{
if
((
string
)
$old
!==
(
string
)
$v
||
$old
===
null
)
{
...
@@ -1225,6 +1201,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1225,6 +1201,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
* count
* count
* this class implements countable interface
* this class implements countable interface
*
*
* Implementation of the Countable interface.
*
* @return integer the number of columns in this record
* @return integer the number of columns in this record
*/
*/
public
function
count
()
public
function
count
()
...
@@ -1436,10 +1414,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1436,10 +1414,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*/
*/
public
function
delete
(
Doctrine_Connection
$conn
=
null
)
public
function
delete
(
Doctrine_Connection
$conn
=
null
)
{
{
if
(
$conn
==
null
)
{
return
$this
->
_mapper
->
delete
(
$this
,
$conn
);
$conn
=
$this
->
_mapper
->
getConnection
();
}
return
$conn
->
unitOfWork
->
delete
(
$this
);
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Relation/Association.php
View file @
71d1150e
...
@@ -107,7 +107,10 @@ class Doctrine_Relation_Association extends Doctrine_Relation
...
@@ -107,7 +107,10 @@ class Doctrine_Relation_Association extends Doctrine_Relation
public
function
fetchRelatedFor
(
Doctrine_Record
$record
)
public
function
fetchRelatedFor
(
Doctrine_Record
$record
)
{
{
$id
=
$record
->
getIncremented
();
$id
=
$record
->
getIncremented
();
//var_dump($id);
//echo "<br /><br />";
if
(
empty
(
$id
)
||
!
$this
->
_foreignMapper
->
getAttribute
(
Doctrine
::
ATTR_LOAD_REFERENCES
))
{
if
(
empty
(
$id
)
||
!
$this
->
_foreignMapper
->
getAttribute
(
Doctrine
::
ATTR_LOAD_REFERENCES
))
{
//echo "here" . $this->_foreignMapper->getAttribute(Doctrine::ATTR_LOAD_REFERENCES);
$coll
=
new
Doctrine_Collection
(
$this
->
getForeignComponentName
());
$coll
=
new
Doctrine_Collection
(
$this
->
getForeignComponentName
());
}
else
{
}
else
{
$query
=
Doctrine_Query
::
create
()
->
parseQuery
(
$this
->
getRelationDql
(
1
));
$query
=
Doctrine_Query
::
create
()
->
parseQuery
(
$this
->
getRelationDql
(
1
));
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Sequence/Mysql.php
View file @
71d1150e
...
@@ -47,10 +47,8 @@ class Doctrine_Sequence_Mysql extends Doctrine_Sequence
...
@@ -47,10 +47,8 @@ class Doctrine_Sequence_Mysql extends Doctrine_Sequence
$query
=
'INSERT INTO '
.
$sequenceName
.
' ('
.
$seqcolName
.
') VALUES (NULL)'
;
$query
=
'INSERT INTO '
.
$sequenceName
.
' ('
.
$seqcolName
.
') VALUES (NULL)'
;
try
{
try
{
$this
->
conn
->
exec
(
$query
);
$this
->
conn
->
exec
(
$query
);
}
catch
(
Doctrine_Connection_Exception
$e
)
{
}
catch
(
Doctrine_Connection_Exception
$e
)
{
if
(
$onDemand
&&
$e
->
getPortableCode
()
==
Doctrine
::
ERR_NOSUCHTABLE
)
{
if
(
$onDemand
&&
$e
->
getPortableCode
()
==
Doctrine
::
ERR_NOSUCHTABLE
)
{
try
{
try
{
$this
->
conn
->
export
->
createSequence
(
$seqName
);
$this
->
conn
->
export
->
createSequence
(
$seqName
);
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Sequence/Pgsql.php
View file @
71d1150e
...
@@ -47,7 +47,7 @@ class Doctrine_Sequence_Pgsql extends Doctrine_Sequence
...
@@ -47,7 +47,7 @@ class Doctrine_Sequence_Pgsql extends Doctrine_Sequence
$query
=
"SELECT NEXTVAL('"
.
$sequenceName
.
"')"
;
$query
=
"SELECT NEXTVAL('"
.
$sequenceName
.
"')"
;
try
{
try
{
$result
=
(
int
)
$this
->
conn
->
fetchOne
(
$query
);
$result
=
(
int
)
$this
->
conn
->
fetchOne
(
$query
);
}
catch
(
Doctrine_Connection_Exception
$e
)
{
}
catch
(
Doctrine_Connection_Exception
$e
)
{
if
(
$onDemand
&&
$e
->
getPortableCode
()
==
Doctrine
::
ERR_NOSUCHTABLE
)
{
if
(
$onDemand
&&
$e
->
getPortableCode
()
==
Doctrine
::
ERR_NOSUCHTABLE
)
{
try
{
try
{
...
@@ -70,6 +70,7 @@ class Doctrine_Sequence_Pgsql extends Doctrine_Sequence
...
@@ -70,6 +70,7 @@ class Doctrine_Sequence_Pgsql extends Doctrine_Sequence
* @param string name of the table into which a new row was inserted
* @param string name of the table into which a new row was inserted
* @param string name of the field into which a new row was inserted
* @param string name of the field into which a new row was inserted
* @return integer the autoincremented id
* @return integer the autoincremented id
* @todo Why not use $this->conn->getDbh()->lastInsertId($sequenceName) ?
*/
*/
public
function
lastInsertId
(
$table
=
null
,
$field
=
null
)
public
function
lastInsertId
(
$table
=
null
,
$field
=
null
)
{
{
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Table.php
View file @
71d1150e
...
@@ -437,6 +437,11 @@ class Doctrine_Table extends Doctrine_Configurable implements Serializable
...
@@ -437,6 +437,11 @@ class Doctrine_Table extends Doctrine_Configurable implements Serializable
$fieldName
=
$parts
[
0
];
$fieldName
=
$parts
[
0
];
}
}
$name
=
strtolower
(
$parts
[
0
]);
$name
=
strtolower
(
$parts
[
0
]);
if
(
isset
(
$this
->
_columnNames
[
$fieldName
]))
{
return
;
}
if
(
$prepend
)
{
if
(
$prepend
)
{
$this
->
_columnNames
=
array_merge
(
array
(
$fieldName
=>
$name
),
$this
->
_columnNames
);
$this
->
_columnNames
=
array_merge
(
array
(
$fieldName
=>
$name
),
$this
->
_columnNames
);
$this
->
_fieldNames
=
array_merge
(
array
(
$name
=>
$fieldName
),
$this
->
_fieldNames
);
$this
->
_fieldNames
=
array_merge
(
array
(
$name
=>
$fieldName
),
$this
->
_fieldNames
);
...
@@ -493,6 +498,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Serializable
...
@@ -493,6 +498,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Serializable
if
(
isset
(
$options
[
'default'
]))
{
if
(
isset
(
$options
[
'default'
]))
{
$this
->
hasDefaultValues
=
true
;
$this
->
hasDefaultValues
=
true
;
}
}
$this
->
columnCount
++
;
}
}
/**
/**
...
@@ -633,11 +640,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Serializable
...
@@ -633,11 +640,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Serializable
{
{
return
$this
->
columnCount
;
return
$this
->
columnCount
;
}
}
public
function
setColumnCount
(
$count
)
{
$this
->
columnCount
=
$count
;
}
/**
/**
* returns all columns and their definitions
* returns all columns and their definitions
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Table/Factory.php
View file @
71d1150e
...
@@ -200,11 +200,9 @@ class Doctrine_Table_Factory
...
@@ -200,11 +200,9 @@ class Doctrine_Table_Factory
$table
->
setOption
(
'declaringClass'
,
$class
);
$table
->
setOption
(
'declaringClass'
,
$class
);
// set the table definition for the given tree implementation
// set the table definition for the given tree implementation
if
(
$table
->
isTree
())
{
/*
if ($table->isTree()) {
$table->getTree()->setTableDefinition();
$table->getTree()->setTableDefinition();
}
}*/
$table
->
setColumnCount
(
count
(
$table
->
getColumns
()));
$tableName
=
$table
->
getOption
(
'tableName'
);
$tableName
=
$table
->
getOption
(
'tableName'
);
if
(
!
isset
(
$tableName
))
{
if
(
!
isset
(
$tableName
))
{
...
@@ -217,9 +215,9 @@ class Doctrine_Table_Factory
...
@@ -217,9 +215,9 @@ class Doctrine_Table_Factory
$record
->
setUp
();
$record
->
setUp
();
// if tree, set up tree relations
// if tree, set up tree relations
if
(
$table
->
isTree
())
{
/*
if ($table->isTree()) {
$table->getTree()->setUp();
$table->getTree()->setUp();
}
}
*/
return
$table
;
return
$table
;
}
}
...
@@ -304,8 +302,6 @@ class Doctrine_Table_Factory
...
@@ -304,8 +302,6 @@ class Doctrine_Table_Factory
$table
->
setIdentifier
(
'id'
);
$table
->
setIdentifier
(
'id'
);
$table
->
setIdentifierType
(
Doctrine
::
IDENTIFIER_AUTOINC
);
$table
->
setIdentifierType
(
Doctrine
::
IDENTIFIER_AUTOINC
);
}
}
$currentCount
=
$table
->
getColumnCount
();
$table
->
setColumnCount
(
++
$currentCount
);
break
;
break
;
case
1
:
case
1
:
foreach
(
$table
->
getIdentifier
()
as
$pk
)
{
foreach
(
$table
->
getIdentifier
()
as
$pk
)
{
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Table/Repository.php
View file @
71d1150e
...
@@ -51,9 +51,9 @@ class Doctrine_Table_Repository implements Countable, IteratorAggregate
...
@@ -51,9 +51,9 @@ class Doctrine_Table_Repository implements Countable, IteratorAggregate
*
*
* @param Doctrine_Table $table
* @param Doctrine_Table $table
*/
*/
public
function
__construct
(
Doctrine_Mapper
$table
)
public
function
__construct
(
Doctrine_Mapper
_Abstract
$mapper
)
{
{
$this
->
table
=
$
table
;
$this
->
table
=
$
mapper
;
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Transaction.php
View file @
71d1150e
...
@@ -326,11 +326,6 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
...
@@ -326,11 +326,6 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
public
function
rollback
(
$savepoint
=
null
)
public
function
rollback
(
$savepoint
=
null
)
{
{
if
(
$this
->
_nestingLevel
==
0
)
{
if
(
$this
->
_nestingLevel
==
0
)
{
/*try {
throw new Doctrine_Transaction_Exception("Rollback failed. There is no active transaction.");
} catch (Exception $e) {
echo $e->getTraceAsString() . "<br />";
}*/
throw
new
Doctrine_Transaction_Exception
(
"Rollback failed. There is no active transaction."
);
throw
new
Doctrine_Transaction_Exception
(
"Rollback failed. There is no active transaction."
);
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/Tree/NestedSet.php
View file @
71d1150e
...
@@ -319,39 +319,4 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
...
@@ -319,39 +319,4 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
$this
->
_baseQuery
=
$this
->
_createBaseQuery
();
$this
->
_baseQuery
=
$this
->
_createBaseQuery
();
}
}
/**
* Enter description here...
*
* @param unknown_type $graph
*/
/*
public function computeLevels($tree)
{
$right = array();
$isArray = is_array($tree);
$rootColumnName = $this->getAttribute('rootColumnName');
for ($i = 0, $count = count($tree); $i < $count; $i++) {
if ($rootColumnName && $i > 0 && $tree[$i][$rootColumnName] != $tree[$i-1][$rootColumnName]) {
$right = array();
}
if (count($right) > 0) {
while (count($right) > 0 && $right[count($right)-1] < $tree[$i]['rgt']) {
//echo count($right);
array_pop($right);
}
}
if ($isArray) {
$tree[$i]['level'] = count($right);
} else {
$tree[$i]->getNode()->setLevel(count($right));
}
$right[] = $tree[$i]['rgt'];
}
return $tree;
}
*/
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/ConnectionTestCase.php
View file @
71d1150e
...
@@ -151,9 +151,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase
...
@@ -151,9 +151,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase
public
function
testDelete
()
public
function
testDelete
()
{
{
$user
=
$this
->
connection
->
create
(
'User'
);
//
$user = $this->connection->create('User');
$this
->
connection
->
unitOfWork
->
delete
(
$user
);
//
$this->connection->unitOfWork->delete($user);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_TCLEAN
);
//
$this->assertEqual($user->state(),Doctrine_Record::STATE_TCLEAN);
}
}
public
function
testGetTable
()
public
function
testGetTable
()
...
...
This diff is collapsed.
Click to expand it.
tests/Inheritance/JoinedTestCase.php
View file @
71d1150e
...
@@ -140,6 +140,40 @@ class Doctrine_Inheritance_Joined_TestCase extends Doctrine_UnitTestCase
...
@@ -140,6 +140,40 @@ class Doctrine_Inheritance_Joined_TestCase extends Doctrine_UnitTestCase
$this
->
assertEqual
(
'Billy the Kid'
,
$superManager
->
gosutitle
);
$this
->
assertEqual
(
'Billy the Kid'
,
$superManager
->
gosutitle
);
$this
->
assertEqual
(
4
,
$superManager
->
type
);
$this
->
assertEqual
(
4
,
$superManager
->
type
);
}
}
public
function
testDqlQueryJoinsTransparentlyAcrossParents
()
{
$this
->
_createManager
();
$this
->
conn
->
getMapper
(
'CTI_Manager'
)
->
clear
();
$query
=
$this
->
conn
->
createQuery
();
$query
->
parseQuery
(
"SELECT m.* FROM CTI_Manager m"
);
$manager
=
$query
->
execute
()
->
getFirst
();
$this
->
assertTrue
(
$manager
instanceof
CTI_Manager
);
$this
->
assertEqual
(
1
,
$manager
->
id
);
$this
->
assertEqual
(
80000
,
$manager
->
salary
);
$this
->
assertEqual
(
'John Smith'
,
$manager
->
name
);
$this
->
assertEqual
(
2
,
$manager
->
type
);
}
public
function
testQueryingBaseClassOuterJoinsSubClassesAndReturnsSubclassInstances
()
{
$this
->
_createManager
();
$this
->
conn
->
getMapper
(
'CTI_Manager'
)
->
clear
();
$this
->
conn
->
getMapper
(
'CTI_User'
)
->
clear
();
$query
=
$this
->
conn
->
createQuery
();
$query
->
parseQuery
(
"SELECT u.* FROM CTI_User u"
);
//echo $query->getSql();
$user
=
$query
->
execute
()
->
getFirst
();
$this
->
assertTrue
(
$user
instanceof
CTI_Manager
);
$this
->
assertEqual
(
1
,
$user
->
id
);
$this
->
assertEqual
(
80000
,
$user
->
salary
);
$this
->
assertEqual
(
'John Smith'
,
$user
->
name
);
$this
->
assertEqual
(
2
,
$user
->
type
);
}
}
}
...
@@ -152,7 +186,15 @@ class CTI_User extends Doctrine_Record
...
@@ -152,7 +186,15 @@ class CTI_User extends Doctrine_Record
'CTI_Manager'
=>
array
(
'type'
=>
2
),
'CTI_Manager'
=>
array
(
'type'
=>
2
),
'CTI_Customer'
=>
array
(
'type'
=>
3
),
'CTI_Customer'
=>
array
(
'type'
=>
3
),
'CTI_SuperManager'
=>
array
(
'type'
=>
4
))
'CTI_SuperManager'
=>
array
(
'type'
=>
4
))
);
);
/*
$class->setInheritanceType(Doctrine::INHERITANCETYPE_JOINED, array(
'discriminatorColumn' => 'type',
'map' => array(1 => 'CTI_User', 2 => 'CTI_Manager', 3 => 'CTI_Customer',
4 => 'CTI_SuperManager')
));
$class->setDiscriminatorValue(1);
$class->setInheritanceOption('fetchType', 'explicit');
*/
$this
->
setTableName
(
'cti_user'
);
$this
->
setTableName
(
'cti_user'
);
$this
->
hasColumn
(
'cti_id as id'
,
'integer'
,
4
,
array
(
'primary'
=>
true
,
'autoincrement'
=>
true
));
$this
->
hasColumn
(
'cti_id as id'
,
'integer'
,
4
,
array
(
'primary'
=>
true
,
'autoincrement'
=>
true
));
$this
->
hasColumn
(
'cti_foo as foo'
,
'integer'
,
4
);
$this
->
hasColumn
(
'cti_foo as foo'
,
'integer'
,
4
);
...
...
This diff is collapsed.
Click to expand it.
tests/Inheritance/SingleTableTestCase.php
View file @
71d1150e
...
@@ -58,6 +58,16 @@ class Doctrine_Inheritance_SingleTable_TestCase extends Doctrine_UnitTestCase
...
@@ -58,6 +58,16 @@ class Doctrine_Inheritance_SingleTable_TestCase extends Doctrine_UnitTestCase
$this
->
fail
(
"Saving record in single table inheritance failed: "
.
$e
->
getMessage
());
$this
->
fail
(
"Saving record in single table inheritance failed: "
.
$e
->
getMessage
());
}
}
}
}
public
function
testQuery
()
{
//$this->_createManager();
$query
=
$this
->
conn
->
createQuery
();
$query
->
select
(
"m.*"
)
->
from
(
"STI_Manager m"
);
//echo $query->getSql();
//$managers = $query->execute();
}
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/Query/JoinCondition2TestCase.php
View file @
71d1150e
...
@@ -74,7 +74,7 @@ class Doctrine_Query_JoinCondition2_TestCase extends Doctrine_UnitTestCase
...
@@ -74,7 +74,7 @@ class Doctrine_Query_JoinCondition2_TestCase extends Doctrine_UnitTestCase
// Should only find zYne
// Should only find zYne
$this
->
assertEqual
(
$rs
->
count
(),
1
);
$this
->
assertEqual
(
$rs
->
count
(),
1
);
// Grab the number of runned queries
// Grab the number of runned queries
$queryCount
=
$this
->
connection
->
count
();
$queryCount
=
$this
->
connection
->
count
();
...
...
This diff is collapsed.
Click to expand it.
tests/Query/MultiJoin2TestCase.php
View file @
71d1150e
...
@@ -85,7 +85,7 @@ class Doctrine_Query_MultiJoin2_TestCase extends Doctrine_UnitTestCase
...
@@ -85,7 +85,7 @@ class Doctrine_Query_MultiJoin2_TestCase extends Doctrine_UnitTestCase
->
execute
();
->
execute
();
// Test that accessing a loaded (but empty) relation doesnt trigger an extra query
// Test that accessing a loaded (but empty) relation doesnt trigger an extra query
$this
->
assertEqual
(
$queryCount
+
1
,
$this
->
connection
->
count
());
$this
->
assertEqual
(
$queryCount
+
1
,
$this
->
connection
->
count
());
$this
->
assertEqual
(
0
,
count
(
$categories
[
0
]
->
subCategories
));
$categories
[
0
]
->
subCategories
;
$categories
[
0
]
->
subCategories
;
$this
->
assertEqual
(
$queryCount
+
1
,
$this
->
connection
->
count
());
$this
->
assertEqual
(
$queryCount
+
1
,
$this
->
connection
->
count
());
}
catch
(
Doctrine_Exception
$e
)
{
}
catch
(
Doctrine_Exception
$e
)
{
...
...
This diff is collapsed.
Click to expand it.
tests/QueryTestCase.php
View file @
71d1150e
...
@@ -101,6 +101,27 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase
...
@@ -101,6 +101,27 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase
//Doctrine::dump($q->getCachedForm(array('foo' => 'bar')));
//Doctrine::dump($q->getCachedForm(array('foo' => 'bar')));
$this
->
assertEqual
(
$q
->
parseClause
(
"CONCAT('u.name', u.name)"
),
"'u.name' || e.name"
);
$this
->
assertEqual
(
$q
->
parseClause
(
"CONCAT('u.name', u.name)"
),
"'u.name' || e.name"
);
}
}
public
function
testUsingDuplicateClassAliasThrowsException
()
{
$q
=
new
Doctrine_Query
();
$q
->
from
(
'User u'
)
->
leftJoin
(
'u.Phonenumber u'
);
try
{
$q
->
getSqlQuery
();
$this
->
fail
();
}
catch
(
Doctrine_Query_Exception
$e
)
{
$this
->
pass
();
}
$q
=
new
Doctrine_Query
();
$q
->
parseDqlQuery
(
'FROM User u, u.Phonenumber u'
);
try
{
$q
->
getSqlQuery
();
$this
->
fail
();
}
catch
(
Doctrine_Query_Exception
$e
)
{
$this
->
pass
();
}
}
}
}
class
MyQuery
extends
Doctrine_Query
class
MyQuery
extends
Doctrine_Query
{
{
...
...
This diff is collapsed.
Click to expand it.
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