Neevo Public API
  • Namespace
  • Class
  • Tree

Namespaces

  • Neevo
    • Nette
  • None
  • PHP

Classes

  • Neevo
  • NeevoBaseStmt
  • NeevoCacheFile
  • NeevoCacheMemcache
  • NeevoCacheMemory
  • NeevoCacheSession
  • NeevoConnection
  • NeevoDriverMySQL
  • NeevoDriverMySQLi
  • NeevoDriverPgSQL
  • NeevoDriverSQLite2
  • NeevoDriverSQLite3
  • NeevoLiteral
  • NeevoLoader
  • NeevoObserverMap
  • NeevoParser
  • NeevoResult
  • NeevoResultIterator
  • NeevoRow
  • NeevoStmt

Interfaces

  • INeevoCache
  • INeevoDriver
  • INeevoObservable
  • INeevoObserver

Exceptions

  • NeevoDriverException
  • NeevoException
  • NeevoImplementationException
  1 <?php
  2 /**
  3  * Neevo - Tiny database layer for PHP. (http://neevo.smasty.net)
  4  *
  5  * This source file is subject to the MIT license that is bundled
  6  * with this package in the file license.txt.
  7  *
  8  * Copyright (c) 2011 Martin Srank (http://smasty.net)
  9  *
 10  */
 11 
 12 
 13 /**
 14  * Main Neevo exception.
 15  * @author Martin Srank
 16  * @package Neevo
 17  */
 18 class NeevoException extends Exception implements INeevoObservable {
 19 
 20 
 21     /** @var string */
 22     protected $sql;
 23 
 24     /** @var NeevoObserverMap */
 25     protected static $observers;
 26 
 27 
 28     /**
 29      * Construct exception.
 30      * @param string $message
 31      * @param int $code
 32      * @param string $sql Optional SQL command
 33      * @param Exception $previous
 34      * @return void
 35      */
 36     public function __construct($message = '', $code = 0, $sql = null, Exception $previous = null){
 37 
 38         parent::__construct($message, (int) $code, $previous);
 39         $this->sql = $sql;
 40         self::$observers = new NeevoObserverMap;
 41         $this->notifyObservers(INeevoObserver::EXCEPTION);
 42     }
 43 
 44 
 45     /**
 46      * String representation of exception.
 47      * @return string
 48      */
 49     public function __toString(){
 50         return parent::__toString() . ($this->sql ? "\nSQL: $this->sql" : '');
 51     }
 52 
 53 
 54     /**
 55      * Get given SQL command.
 56      * @return string
 57      */
 58     public function getSql(){
 59         return $this->sql;
 60     }
 61 
 62 
 63     /*  ============  Implementation of INeevoObservable  ============  */
 64 
 65 
 66     /**
 67      * Attach given observer to given event.
 68      * @param INeevoObserver $observer
 69      * @param int $event
 70      * @return void
 71      */
 72     public function attachObserver(INeevoObserver $observer, $event){
 73         self::$observers->attach($observer, $event);
 74     }
 75 
 76 
 77     /**
 78      * Detach given observer.
 79      * @param INeevoObserver $observer
 80      * @return void
 81      */
 82     public function detachObserver(INeevoObserver $observer){
 83         self::$observers->detach($observer);
 84     }
 85 
 86 
 87     /**
 88      * Notify all observers attached to given event.
 89      * @param int $event
 90      * @return void
 91      */
 92     public function notifyObservers($event){
 93         foreach(self::$observers as $observer){
 94             if($event & self::$observers->getEvent())
 95                 $observer->updateStatus($this, $event);
 96         }
 97     }
 98 
 99 
100 }
101 
102 
103 
104 /**
105  * Exception for features not implemented by the driver.
106  * @author Martin Srank
107  * @package Neevo\Drivers
108  */
109 class NeevoImplementationException extends NeevoException {}
110 
111 
112 
113 /**
114  * Neevo driver exception.
115  * @author Martin Srank
116  * @package Neevo\Drivers
117  */
118 class NeevoDriverException extends NeevoException {}
119 
Neevo Public API API documentation generated by ApiGen 2.8.0