Commit e2cb1585 authored by zYne's avatar zYne

db eventlisteners updated

parent 5b594a54
......@@ -18,6 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine::autoload('Doctrine_Db_EventListener');
/**
* Doctrine_Db_Cache
*
......@@ -32,48 +33,13 @@
*/
class Doctrine_Db_Cache extends Doctrine_Db_EventListener
{
public function __construct($cacheDriver)
{
}
public function onPreQuery(Doctrine_Db_Event $event)
{
$query = $event->getQuery();
$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)
{
}
protected $cache;
public function onPreExec(Doctrine_Db_Event $event)
{
}
public function onExec(Doctrine_Db_Event $event)
{
public function __construct(Doctrine_Cache $cache)
{
$this->cache = $cache;
}
public function onPreExecute(Doctrine_Db_Event $event)
{
$query = $event->getQuery();
$this->cache->process($query);
}
public function onExecute(Doctrine_Db_Event $event)
{
}
}
......@@ -55,6 +55,16 @@ class Doctrine_Db_EventListener implements Doctrine_Db_EventListener_Interface
{ }
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)
{ }
......
......@@ -130,6 +130,31 @@ class Doctrine_Db_EventListener_Chain extends Doctrine_Access implements Doctrin
$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)
{
......
......@@ -38,6 +38,12 @@ interface Doctrine_Db_EventListener_Interface {
public function onPreExec(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 onCommit(Doctrine_Db_Event $event);
......
......@@ -29,42 +29,20 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Db_Statement extends PDOStatement
class Doctrine_Db_Statement implements Doctrine_Adapter_Statement_Interface
{
protected $dbh;
protected $querySequence;
protected $baseSequence;
protected $executed = false;
protected function __construct($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()
{
return $this->queryString;
}
public function isExecuted($executed = null)
{
if ($executed === null)
return $this->executed;
$this->executed = (bool) $executed;
}
public function execute(array $params = null)
{
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::EXECUTE, $this->queryString, $params);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment