1
0
mirror of synced 2024-12-13 22:56:04 +03:00

db eventlisteners updated

This commit is contained in:
zYne 2007-02-01 08:57:56 +00:00
parent 5b594a5468
commit e2cb1585f6
5 changed files with 47 additions and 62 deletions

View File

@ -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
{
protected $cache;
public function __construct($cacheDriver)
public function __construct(Doctrine_Cache $cache)
{
}
public function onPreQuery(Doctrine_Db_Event $event)
{
$query = $event->getQuery();
$this->cache->process($query);
}
public function onQuery(Doctrine_Db_Event $event)
{
$this->cache = $cache;
}
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)
{
}
}

View File

@ -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)
{ }

View File

@ -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)
{

View File

@ -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);

View File

@ -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);