[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/vendor/creole/ -> SQLException.php (source)

   1  <?php
   2  /*
   3   *  $Id: SQLException.php,v 1.10 2004/03/20 04:16:49 hlellelid Exp $
   4   *
   5   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   6   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   7   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   8   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   9   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16   *
  17   * This software consists of voluntary contributions made by many individuals
  18   * and is licensed under the LGPL. For more information please see
  19   * <http://creole.phpdb.org>.
  20   */
  21  
  22  /**
  23   * A class for handling database-related errors.
  24   *
  25   * @author    Hans Lellelid <hans@xmpl.org>
  26   * @version   $Revision: 1.10 $
  27   * @package   creole
  28   */
  29  class SQLException extends Exception {
  30      
  31      /** Information that provides additional information for context of Exception (e.g. SQL statement or DSN). */
  32      protected $userInfo;
  33      
  34      /** Native RDBMS error string */
  35      protected $nativeError;
  36      
  37      /**
  38       * Constructs a SQLException.
  39       * @param string $msg Error message
  40       * @param string $native Native DB error message.
  41       * @param string $userinfo More info, e.g. the SQL statement or the connection string that caused the error.
  42       */
  43      public function __construct($msg, $native = null, $userinfo = null)
  44      {
  45          parent::__construct($msg);
  46          if ($native !== null) {
  47              $this->setNativeError($native);
  48          }
  49          if ($userinfo !== null) {
  50              $this->setUserInfo($userinfo);
  51          }
  52      }
  53      
  54      /**
  55       * Sets additional user / debug information for this error.
  56       *  
  57       * @param array $info
  58       * @return void
  59       */ 
  60      public function setUserInfo($info)
  61      {
  62          $this->userInfo = $info;
  63          $this->message .= " [User Info: " .$this->userInfo . "]";
  64      }
  65      
  66      /**
  67       * Returns the additional / debug information for this error. 
  68       * 
  69       * @return array hash of user info properties.
  70       */
  71      public function getUserInfo()
  72      {
  73          return $this->userInfo;
  74      }
  75      
  76      /**
  77       * Sets driver native error message.
  78       *  
  79       * @param string $info
  80       * @return void
  81       */ 
  82      public function setNativeError($msg)
  83      {
  84          $this->nativeError = $msg;
  85          $this->message .= " [Native Error: " .$this->nativeError . "]";
  86      }
  87      
  88      /**
  89       * Gets driver native error message.
  90       * 
  91       * @return string
  92       */
  93      public function getNativeError()
  94      {
  95          return $this->nativeError;
  96      }        
  97      
  98      /**
  99       * @deprecated This method only exists right now for easier compatibility w/ PHPUnit!
 100       */
 101      public function toString()
 102      {
 103          return $this->getMessage();
 104      }
 105  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7