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
f855a02d
Commit
f855a02d
authored
Oct 23, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DDC-217 - Move factory method into Connection
parent
120172a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
5 deletions
+36
-5
ResultCacheStatement.php
lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
+5
-3
Connection.php
lib/Doctrine/DBAL/Connection.php
+31
-2
No files found.
lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
View file @
f855a02d
...
@@ -19,9 +19,11 @@
...
@@ -19,9 +19,11 @@
namespace
Doctrine\DBAL\Cache
;
namespace
Doctrine\DBAL\Cache
;
use
Doctrine\DBAL\Driver\Statement
;
use
Doctrine\DBAL\Driver\ResultStatement
;
use
Doctrine\DBAL\Driver\ResultStatement
;
use
PDO
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\Common\Cache\Cache
;
use
PDO
;
/**
/**
* Cache statement for SQL results.
* Cache statement for SQL results.
...
@@ -99,13 +101,13 @@ class ResultCacheStatement implements ResultStatement
...
@@ -99,13 +101,13 @@ class ResultCacheStatement implements ResultStatement
}
}
/**
/**
*
* @param Statement $stmt
* @param Statement $stmt
* @param Cache $resultCache
* @param Cache $resultCache
* @param string $cacheKey
* @param string $cacheKey
* @param string $realKey
* @param int $lifetime
* @param int $lifetime
*/
*/
p
rivate
function
__construct
(
$stmt
,
$resultCache
,
$cacheKey
,
$realKey
,
$lifetime
)
p
ublic
function
__construct
(
Statement
$stmt
,
Cache
$resultCache
,
$cacheKey
,
$realKey
,
$lifetime
)
{
{
$this
->
statement
=
$stmt
;
$this
->
statement
=
$stmt
;
$this
->
resultCache
=
$resultCache
;
$this
->
resultCache
=
$resultCache
;
...
...
lib/Doctrine/DBAL/Connection.php
View file @
f855a02d
...
@@ -25,7 +25,8 @@ use PDO, Closure, Exception,
...
@@ -25,7 +25,8 @@ use PDO, Closure, Exception,
Doctrine\Common\EventManager
,
Doctrine\Common\EventManager
,
Doctrine\DBAL\DBALException
,
Doctrine\DBAL\DBALException
,
Doctrine\DBAL\Cache\ResultCacheStatement
,
Doctrine\DBAL\Cache\ResultCacheStatement
,
Doctrine\DBAL\Cache\QueryCacheProfile
;
Doctrine\DBAL\Cache\QueryCacheProfile
,
Doctrine\DBAL\Cache\ArrayStatement
;
/**
/**
* A wrapper around a Doctrine\DBAL\Driver\Connection that adds features like
* A wrapper around a Doctrine\DBAL\Driver\Connection that adds features like
...
@@ -603,7 +604,7 @@ class Connection implements DriverConnection
...
@@ -603,7 +604,7 @@ class Connection implements DriverConnection
public
function
executeQuery
(
$query
,
array
$params
=
array
(),
$types
=
array
(),
QueryCacheProfile
$qcp
=
null
)
public
function
executeQuery
(
$query
,
array
$params
=
array
(),
$types
=
array
(),
QueryCacheProfile
$qcp
=
null
)
{
{
if
(
$qcp
!==
null
)
{
if
(
$qcp
!==
null
)
{
return
ResultCacheStatement
::
create
(
$this
,
$query
,
$params
,
$types
,
$qcp
);
return
$this
->
executeCacheQuery
(
$query
,
$params
,
$types
,
$qcp
);
}
}
$this
->
connect
();
$this
->
connect
();
...
@@ -634,6 +635,34 @@ class Connection implements DriverConnection
...
@@ -634,6 +635,34 @@ class Connection implements DriverConnection
return
$stmt
;
return
$stmt
;
}
}
/**
* Execute a caching query and
*
* @param string $query
* @param array $params
* @param array $types
* @param QueryCacheProfile $qcp
* @return \Doctrine\DBAL\Driver\ResultStatement
*/
public
function
executeCacheQuery
(
$query
,
$params
,
$types
,
QueryCacheProfile
$qcp
)
{
$resultCache
=
$qcp
->
getResultCacheDriver
()
?:
$this
->
_config
->
getResultCacheImpl
();
if
(
!
$resultCache
)
{
throw
CacheException
::
noResultDriverConfigured
();
}
list
(
$cacheKey
,
$realKey
)
=
$qcp
->
generateCacheKeys
(
$query
,
$params
,
$types
);
// fetch the row pointers entry
if
(
$data
=
$resultCache
->
fetch
(
$cacheKey
))
{
// is the real key part of this row pointers map or is the cache only pointing to other cache keys?
if
(
isset
(
$data
[
$realKey
]))
{
return
new
ArrayStatement
(
$data
[
$realKey
]);
}
}
return
new
ResultCacheStatement
(
$this
->
executeQuery
(
$query
,
$params
,
$types
),
$resultCache
,
$cacheKey
,
$realKey
,
$qcp
->
getLifetime
());
}
/**
/**
* Executes an, optionally parameterized, SQL query and returns the result,
* Executes an, optionally parameterized, SQL query and returns the result,
* applying a given projection/transformation function on each row of the result.
* applying a given projection/transformation function on each row of the result.
...
...
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