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
8e3f6eee
Commit
8e3f6eee
authored
Nov 08, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-121] Fixed. Also fixed memcache tests and some small refactorings.
parent
7f725aa7
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
84 additions
and
30 deletions
+84
-30
Connection.php
lib/Doctrine/DBAL/Connection.php
+2
-15
Connection.php
lib/Doctrine/DBAL/Driver/Connection.php
+1
-1
DriverManager.php
lib/Doctrine/DBAL/DriverManager.php
+2
-1
SequenceGenerator.php
lib/Doctrine/ORM/Id/SequenceGenerator.php
+1
-1
SingleScalarHydrator.php
lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php
+2
-2
PersistentCollection.php
lib/Doctrine/ORM/PersistentCollection.php
+15
-2
StandardEntityPersister.php
lib/Doctrine/ORM/Persisters/StandardEntityPersister.php
+3
-2
MemcacheCacheTest.php
tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php
+10
-1
ConnectionMock.php
tests/Doctrine/Tests/Mocks/ConnectionMock.php
+1
-1
DriverConnectionMock.php
tests/Doctrine/Tests/Mocks/DriverConnectionMock.php
+1
-1
AdvancedAssociationTest.php
...Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php
+1
-1
BasicFunctionalTest.php
tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php
+42
-0
IdentityMapTest.php
tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php
+1
-0
ManyToManyBidirectionalAssociationTest.php
...ORM/Functional/ManyToManyBidirectionalAssociationTest.php
+2
-2
No files found.
lib/Doctrine/DBAL/Connection.php
View file @
8e3f6eee
...
...
@@ -328,7 +328,7 @@ class Connection
}
/**
* Convenience method for PDO::query("...") followed by $stmt->fetch
All(PDO::FETCH_COLUMN,
...).
* Convenience method for PDO::query("...") followed by $stmt->fetch
Column(
...).
*
* @param string $statement sql query to be executed
* @param array $params prepared statement params
...
...
@@ -337,7 +337,7 @@ class Connection
*/
public
function
fetchColumn
(
$statement
,
array
$params
=
array
(),
$colnum
=
0
)
{
return
$this
->
execute
(
$statement
,
$params
)
->
fetch
All
(
Connection
::
FETCH_COLUMN
,
$colnum
);
return
$this
->
execute
(
$statement
,
$params
)
->
fetch
Column
(
$colnum
);
}
/**
...
...
@@ -536,19 +536,6 @@ class Connection
return
$this
->
execute
(
$sql
,
$params
)
->
fetchAll
(
Connection
::
FETCH_ASSOC
);
}
/**
* Convenience method for PDO::query("...") followed by $stmt->fetchColumn().
*
* @param string $statement The SQL query.
* @param array $params The query parameters.
* @param int $colnum 0-indexed column number to retrieve
* @return mixed
*/
public
function
fetchOne
(
$statement
,
array
$params
=
array
(),
$colnum
=
0
)
{
return
$this
->
execute
(
$statement
,
$params
)
->
fetchColumn
(
$colnum
);
}
/**
* Prepares an SQL statement.
*
...
...
lib/Doctrine/DBAL/Driver/Connection.php
View file @
8e3f6eee
...
...
@@ -35,7 +35,7 @@ interface Connection
function
query
();
function
quote
(
$input
);
function
exec
(
$statement
);
function
lastInsertId
();
function
lastInsertId
(
$name
=
null
);
function
beginTransaction
();
function
commit
();
function
rollBack
();
...
...
lib/Doctrine/DBAL/DriverManager.php
View file @
8e3f6eee
...
...
@@ -43,7 +43,8 @@ final class DriverManager
'pdo_sqlite'
=>
'Doctrine\DBAL\Driver\PDOSqlite\Driver'
,
'pdo_pgsql'
=>
'Doctrine\DBAL\Driver\PDOPgSql\Driver'
,
'pdo_oci'
=>
'Doctrine\DBAL\Driver\PDOOracle\Driver'
,
'pdo_mssql'
=>
'Doctrine\DBAL\Driver\PDOMsSql\Driver'
'pdo_mssql'
=>
'Doctrine\DBAL\Driver\PDOMsSql\Driver'
,
'oci8'
=>
'Doctrine\DBAL\Driver\OCI8\Driver'
);
/** Private constructor. This class cannot be instantiated. */
...
...
lib/Doctrine/ORM/Id/SequenceGenerator.php
View file @
8e3f6eee
...
...
@@ -62,7 +62,7 @@ class SequenceGenerator extends AbstractIdGenerator implements \Serializable
// Allocate new values
$conn
=
$em
->
getConnection
();
$sql
=
$conn
->
getDatabasePlatform
()
->
getSequenceNextValSql
(
$this
->
_sequenceName
);
$this
->
_nextValue
=
$conn
->
fetch
One
(
$sql
);
$this
->
_nextValue
=
$conn
->
fetch
Column
(
$sql
);
$this
->
_maxValue
=
$this
->
_nextValue
+
$this
->
_allocationSize
;
}
return
$this
->
_nextValue
++
;
...
...
lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php
View file @
8e3f6eee
...
...
@@ -36,10 +36,10 @@ class SingleScalarHydrator extends AbstractHydrator
$cache
=
array
();
$result
=
$this
->
_stmt
->
fetchAll
(
Connection
::
FETCH_ASSOC
);
//TODO: Let this exception be raised by Query as QueryException
if
(
count
(
$result
)
>
1
||
count
(
$result
[
0
])
>
1
)
{
if
(
count
(
$result
)
>
1
||
count
(
$result
[
key
(
$result
)
])
>
1
)
{
throw
HydrationException
::
nonUniqueResult
();
}
$result
=
$this
->
_gatherScalarRowData
(
$result
[
0
],
$cache
);
$result
=
$this
->
_gatherScalarRowData
(
$result
[
key
(
$result
)
],
$cache
);
return
array_shift
(
$result
);
}
...
...
lib/Doctrine/ORM/PersistentCollection.php
View file @
8e3f6eee
...
...
@@ -190,7 +190,7 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
}
else
{
// ManyToMany
$this
->
_typeClass
->
reflFields
[
$this
->
_backRefFieldName
]
->
getValue
(
$element
)
->
add
(
$this
->
_owner
);
->
getValue
(
$element
)
->
unwrap
()
->
add
(
$this
->
_owner
);
}
}
}
...
...
@@ -229,8 +229,18 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
private
function
_initialize
()
{
if
(
!
$this
->
_initialized
)
{
if
(
$this
->
_isDirty
)
{
// Has NEW objects added through add(). Remember them.
$newObjects
=
$this
->
_coll
->
toArray
();
}
$this
->
_coll
->
clear
();
$this
->
_association
->
load
(
$this
->
_owner
,
$this
,
$this
->
_em
);
// Reattach NEW objects added through add(), if any.
if
(
isset
(
$newObjects
))
{
foreach
(
$newObjects
as
$obj
)
{
$this
->
_coll
->
add
(
$obj
);
}
}
$this
->
_initialized
=
true
;
}
}
...
...
@@ -242,6 +252,7 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
public
function
takeSnapshot
()
{
$this
->
_snapshot
=
$this
->
_coll
->
toArray
();
$this
->
_isDirty
=
false
;
}
/**
...
...
@@ -267,7 +278,8 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
}
/**
* INTERNAL getInsertDiff
* INTERNAL:
* getInsertDiff
*
* @return array
*/
...
...
@@ -465,6 +477,7 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
*/
public
function
set
(
$key
,
$value
)
{
$this
->
_initialize
();
$this
->
_coll
->
set
(
$key
,
$value
);
$this
->
_changed
();
}
...
...
lib/Doctrine/ORM/Persisters/StandardEntityPersister.php
View file @
8e3f6eee
...
...
@@ -193,7 +193,7 @@ class StandardEntityPersister
$sql
=
"SELECT "
.
$versionFieldColumnName
.
" FROM "
.
$class
->
getQuotedTableName
(
$this
->
_platform
)
.
" WHERE "
.
implode
(
' = ? AND '
,
$identifier
)
.
" = ?"
;
$value
=
$this
->
_conn
->
fetchColumn
(
$sql
,
(
array
)
$id
);
$this
->
_class
->
setFieldValue
(
$entity
,
$versionField
,
$value
[
0
]
);
$this
->
_class
->
setFieldValue
(
$entity
,
$versionField
,
$value
);
}
/**
...
...
@@ -550,7 +550,8 @@ class StandardEntityPersister
$stmt
=
$this
->
_conn
->
prepare
(
$this
->
_getSelectManyToManyEntityCollectionSql
(
$assoc
,
$criteria
));
$stmt
->
execute
(
array_values
(
$criteria
));
while
(
$result
=
$stmt
->
fetch
(
Connection
::
FETCH_ASSOC
))
{
$coll
->
add
(
$this
->
_createEntity
(
$result
));
//$coll->add($this->_createEntity($result));
$coll
->
hydrateAdd
(
$this
->
_createEntity
(
$result
));
}
$stmt
->
closeCursor
();
}
...
...
tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php
View file @
8e3f6eee
...
...
@@ -8,9 +8,17 @@ require_once __DIR__ . '/../../TestInit.php';
class
MemcacheCacheTest
extends
\Doctrine\Tests\DoctrineTestCase
{
private
$_memcache
;
public
function
setUp
()
{
if
(
!
extension_loaded
(
'memcache'
))
{
if
(
extension_loaded
(
'memcache'
))
{
$memcache
=
new
\Memcache
;
$ok
=
@
$memcache
->
connect
(
'localhost'
,
11211
);
if
(
!
$ok
)
{
$this
->
markTestSkipped
(
'The '
.
__CLASS__
.
' requires the use of memcache'
);
}
}
else
{
$this
->
markTestSkipped
(
'The '
.
__CLASS__
.
' requires the use of memcache'
);
}
}
...
...
@@ -18,6 +26,7 @@ class MemcacheCacheTest extends \Doctrine\Tests\DoctrineTestCase
public
function
testMemcacheCacheDriver
()
{
$cache
=
new
MemcacheCache
();
$cache
->
setMemcache
(
$this
->
_memcache
);
// Test save
$cache
->
save
(
'test_key'
,
'testing this out'
);
...
...
tests/Doctrine/Tests/Mocks/ConnectionMock.php
View file @
8e3f6eee
...
...
@@ -43,7 +43,7 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
/**
* @override
*/
public
function
fetch
One
(
$statement
,
array
$params
=
array
(),
$colnum
=
0
)
public
function
fetch
Column
(
$statement
,
array
$params
=
array
(),
$colnum
=
0
)
{
return
$this
->
_fetchOneResult
;
}
...
...
tests/Doctrine/Tests/Mocks/DriverConnectionMock.php
View file @
8e3f6eee
...
...
@@ -8,7 +8,7 @@ class DriverConnectionMock implements \Doctrine\DBAL\Driver\Connection
public
function
query
()
{}
public
function
quote
(
$input
)
{}
public
function
exec
(
$statement
)
{}
public
function
lastInsertId
()
{}
public
function
lastInsertId
(
$name
=
null
)
{}
public
function
beginTransaction
()
{}
public
function
commit
()
{}
public
function
rollBack
()
{}
...
...
tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php
View file @
8e3f6eee
...
...
@@ -94,9 +94,9 @@ class AdvancedAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase
$definitions
=
$res
[
0
]
->
getDefinitions
();
$this
->
assertEquals
(
1
,
count
(
$res
));
$this
->
assertTrue
(
$definitions
[
0
]
instanceof
Definition
);
$this
->
assertEquals
(
2
,
$definitions
->
count
());
}
public
function
testManyToMany
()
...
...
tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php
View file @
8e3f6eee
...
...
@@ -380,6 +380,48 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$gblanco
->
addPhonenumber
(
$newPhone
);
$this
->
assertFalse
(
$gblanco
->
getPhonenumbers
()
->
isInitialized
());
$this
->
_em
->
persist
(
$gblanco
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
$query
=
$this
->
_em
->
createQuery
(
"select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p where u.username='gblanco'"
);
$gblanco2
=
$query
->
getSingleResult
();
$this
->
assertEquals
(
4
,
$gblanco2
->
getPhonenumbers
()
->
count
());
}
public
function
testInitializeCollectionWithNewObjectsRetainsNewObjects
()
{
$user
=
new
CmsUser
;
$user
->
name
=
'Guilherme'
;
$user
->
username
=
'gblanco'
;
$user
->
status
=
'developer'
;
for
(
$i
=
0
;
$i
<
3
;
++
$i
)
{
$phone
=
new
CmsPhonenumber
;
$phone
->
phonenumber
=
100
+
$i
;
$user
->
addPhonenumber
(
$phone
);
}
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
$this
->
assertEquals
(
3
,
$user
->
getPhonenumbers
()
->
count
());
$query
=
$this
->
_em
->
createQuery
(
"select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username='gblanco'"
);
$gblanco
=
$query
->
getSingleResult
();
$this
->
assertFalse
(
$gblanco
->
getPhonenumbers
()
->
isInitialized
());
$newPhone
=
new
CmsPhonenumber
;
$newPhone
->
phonenumber
=
555
;
$gblanco
->
addPhonenumber
(
$newPhone
);
$this
->
assertFalse
(
$gblanco
->
getPhonenumbers
()
->
isInitialized
());
$this
->
assertEquals
(
4
,
$gblanco
->
getPhonenumbers
()
->
count
());
$this
->
assertTrue
(
$gblanco
->
getPhonenumbers
()
->
isInitialized
());
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php
View file @
8e3f6eee
...
...
@@ -178,6 +178,7 @@ class IdentityMapTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
_em
->
flush
();
$this
->
assertEquals
(
3
,
count
(
$user
->
getPhonenumbers
()));
$this
->
assertFalse
(
$user
->
getPhonenumbers
()
->
isDirty
());
//external update to CmsAddress
$this
->
_em
->
getConnection
()
->
executeUpdate
(
'insert into cms_phonenumbers (phonenumber, user_id) VALUES (?,?)'
,
array
(
999
,
$user
->
getId
()));
...
...
tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php
View file @
8e3f6eee
...
...
@@ -110,7 +110,6 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
$this
->
assertLoadingOfOwningSide
(
$products
);
}
private
function
_createLoadingFixture
()
{
$this
->
firstProduct
->
addCategory
(
$this
->
firstCategory
);
...
...
@@ -140,6 +139,7 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
$this
->
assertEquals
(
2
,
count
(
$firstProductCategories
));
$this
->
assertEquals
(
2
,
count
(
$secondProductCategories
));
$this
->
assertTrue
(
$firstProductCategories
[
0
]
===
$secondProductCategories
[
0
]);
$this
->
assertTrue
(
$firstProductCategories
[
1
]
===
$secondProductCategories
[
1
]);
...
...
@@ -148,7 +148,7 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
$this
->
assertEquals
(
2
,
count
(
$firstCategoryProducts
));
$this
->
assertEquals
(
2
,
count
(
$secondCategoryProducts
));
$this
->
assertTrue
(
$firstCategoryProducts
[
0
]
instanceof
ECommerceProduct
);
$this
->
assertTrue
(
$firstCategoryProducts
[
1
]
instanceof
ECommerceProduct
);
$this
->
assertTrue
(
$secondCategoryProducts
[
0
]
instanceof
ECommerceProduct
);
...
...
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