db eventlisteners updated
This commit is contained in:
parent
5b594a5468
commit
e2cb1585f6
@ -18,6 +18,7 @@
|
|||||||
* and is licensed under the LGPL. For more information, see
|
* and is licensed under the LGPL. For more information, see
|
||||||
* <http://www.phpdoctrine.com>.
|
* <http://www.phpdoctrine.com>.
|
||||||
*/
|
*/
|
||||||
|
Doctrine::autoload('Doctrine_Db_EventListener');
|
||||||
/**
|
/**
|
||||||
* Doctrine_Db_Cache
|
* Doctrine_Db_Cache
|
||||||
*
|
*
|
||||||
@ -33,47 +34,12 @@
|
|||||||
class Doctrine_Db_Cache extends Doctrine_Db_EventListener
|
class Doctrine_Db_Cache extends Doctrine_Db_EventListener
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct($cacheDriver)
|
protected $cache;
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public function __construct(Doctrine_Cache $cache)
|
||||||
public function onPreQuery(Doctrine_Db_Event $event)
|
|
||||||
{
|
{
|
||||||
$query = $event->getQuery();
|
$this->cache = $cache;
|
||||||
|
|
||||||
$this->cache->process($query);
|
|
||||||
}
|
|
||||||
public function onQuery(Doctrine_Db_Event $event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPrePrepare(Doctrine_Db_Event $event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
public function onPrepare(Doctrine_Db_Event $event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onPreExec(Doctrine_Db_Event $event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
public function onExec(Doctrine_Db_Event $event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onPreExecute(Doctrine_Db_Event $event)
|
|
||||||
{
|
|
||||||
$query = $event->getQuery();
|
|
||||||
|
|
||||||
$this->cache->process($query);
|
|
||||||
}
|
|
||||||
public function onExecute(Doctrine_Db_Event $event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,16 @@ class Doctrine_Db_EventListener implements Doctrine_Db_EventListener_Interface
|
|||||||
public function onExec(Doctrine_Db_Event $event)
|
public function onExec(Doctrine_Db_Event $event)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
public function onPreFetch(Doctrine_Db_Event $event)
|
||||||
|
{ }
|
||||||
|
public function onFetch(Doctrine_Db_Event $event)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public function onPreFetchAll(Doctrine_Db_Event $event)
|
||||||
|
{ }
|
||||||
|
public function onFetchAll(Doctrine_Db_Event $event)
|
||||||
|
{ }
|
||||||
|
|
||||||
public function onPreRollBack(Doctrine_Db_Event $event)
|
public function onPreRollBack(Doctrine_Db_Event $event)
|
||||||
{ }
|
{ }
|
||||||
public function onRollBack(Doctrine_Db_Event $event)
|
public function onRollBack(Doctrine_Db_Event $event)
|
||||||
|
@ -130,6 +130,31 @@ class Doctrine_Db_EventListener_Chain extends Doctrine_Access implements Doctrin
|
|||||||
$listener->onCommit($event);
|
$listener->onCommit($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public function onPreFetch(Doctrine_Db_Event $event)
|
||||||
|
{
|
||||||
|
foreach ($this->listeners as $listener) {
|
||||||
|
$listener->onPreFetch($event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function onFetch(Doctrine_Db_Event $event)
|
||||||
|
{
|
||||||
|
foreach ($this->listeners as $listener) {
|
||||||
|
$listener->onFetch($event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onPreFetchAll(Doctrine_Db_Event $event)
|
||||||
|
{
|
||||||
|
foreach ($this->listeners as $listener) {
|
||||||
|
$listener->onPreFetchAll($event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function onFetchAll(Doctrine_Db_Event $event)
|
||||||
|
{
|
||||||
|
foreach ($this->listeners as $listener) {
|
||||||
|
$listener->onFetchAll($event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function onPreRollBack(Doctrine_Db_Event $event)
|
public function onPreRollBack(Doctrine_Db_Event $event)
|
||||||
{
|
{
|
||||||
|
@ -38,6 +38,12 @@ interface Doctrine_Db_EventListener_Interface {
|
|||||||
public function onPreExec(Doctrine_Db_Event $event);
|
public function onPreExec(Doctrine_Db_Event $event);
|
||||||
public function onExec(Doctrine_Db_Event $event);
|
public function onExec(Doctrine_Db_Event $event);
|
||||||
|
|
||||||
|
public function onPreFetch(Doctrine_Db_Event $event);
|
||||||
|
public function onFetch(Doctrine_Db_Event $event);
|
||||||
|
|
||||||
|
public function onPreFetchAll(Doctrine_Db_Event $event);
|
||||||
|
public function onFetchAll(Doctrine_Db_Event $event);
|
||||||
|
|
||||||
public function onPreCommit(Doctrine_Db_Event $event);
|
public function onPreCommit(Doctrine_Db_Event $event);
|
||||||
public function onCommit(Doctrine_Db_Event $event);
|
public function onCommit(Doctrine_Db_Event $event);
|
||||||
|
|
||||||
|
@ -29,42 +29,20 @@
|
|||||||
* @since 1.0
|
* @since 1.0
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
class Doctrine_Db_Statement extends PDOStatement
|
class Doctrine_Db_Statement implements Doctrine_Adapter_Statement_Interface
|
||||||
{
|
{
|
||||||
protected $dbh;
|
protected $dbh;
|
||||||
|
|
||||||
protected $querySequence;
|
|
||||||
|
|
||||||
protected $baseSequence;
|
|
||||||
|
|
||||||
protected $executed = false;
|
protected $executed = false;
|
||||||
|
|
||||||
protected function __construct($dbh)
|
protected function __construct($dbh)
|
||||||
{
|
{
|
||||||
$this->dbh = $dbh;
|
$this->dbh = $dbh;
|
||||||
$this->baseSequence = $this->querySequence = $this->dbh->getQuerySequence();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getQuerySequence()
|
|
||||||
{
|
|
||||||
return $this->querySequence;
|
|
||||||
}
|
|
||||||
public function getBaseSequence()
|
|
||||||
{
|
|
||||||
return $this->baseSequence;
|
|
||||||
}
|
}
|
||||||
public function getQuery()
|
public function getQuery()
|
||||||
{
|
{
|
||||||
return $this->queryString;
|
return $this->queryString;
|
||||||
}
|
}
|
||||||
public function isExecuted($executed = null)
|
|
||||||
{
|
|
||||||
if ($executed === null)
|
|
||||||
return $this->executed;
|
|
||||||
|
|
||||||
$this->executed = (bool) $executed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function execute(array $params = null)
|
public function execute(array $params = null)
|
||||||
{
|
{
|
||||||
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::EXECUTE, $this->queryString, $params);
|
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::EXECUTE, $this->queryString, $params);
|
||||||
|
Loading…
Reference in New Issue
Block a user