[ Index ]
 

Code source de Symfony 1.0.0

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

title

Body

[fermer]

/lib/vendor/propel/adapter/ -> DBAdapter.php (source)

   1  <?php
   2  
   3  /*
   4   *  $Id: DBAdapter.php 325 2006-01-17 19:12:40Z hans $
   5   *
   6   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   7   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   8   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   9   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  10   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  11   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  13   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  16   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17   *
  18   * This software consists of voluntary contributions made by many individuals
  19   * and is licensed under the LGPL. For more information please see
  20   * <http://propel.phpdb.org>.
  21   */
  22   
  23  include_once 'creole/Connection.php';
  24  
  25  /**
  26   * DBAdapter</code> defines the interface for a Propel database adapter.  
  27   * 
  28   * <p>Support for new databases is added by subclassing
  29   * <code>DBAdapter</code> and implementing its abstract interface, and by
  30   * registering the new database adapter and corresponding Creole
  31   * driver in the private adapters map (array) in this class.</p>
  32   *
  33   * <p>The Propel database adapters exist to present a uniform
  34   * interface to database access across all available databases.  Once
  35   * the necessary adapters have been written and configured,
  36   * transparent swapping of databases is theoretically supported with
  37   * <i>zero code change</i> and minimal configuration file
  38   * modifications.</p>
  39   * 
  40   * @author Hans Lellelid <hans@xmpl.org> (Propel)
  41   * @author Jon S. Stevens <jon@latchkey.com> (Torque)
  42   * @author Brett McLaughlin <bmclaugh@algx.net> (Torque)
  43   * @author Daniel Rall <dlr@finemaltcoding.com> (Torque)
  44   * @version $Revision: 325 $
  45   * @package propel.adapter
  46   */
  47  abstract class DBAdapter {
  48      
  49      /**
  50       * Creole driver to Propel adapter map.
  51       * @var array
  52       */
  53      private static $adapters = array(
  54                                      'mysql' => 'DBMySQL',
  55                                      'mysqli' => 'DBMySQLi',
  56                                      'mssql' => 'DBMSSQL',
  57                                      'sybase' => 'DBSyabase',
  58                                      'oracle' => 'DBOracle',
  59                                      'pgsql' => 'DBPostgres',
  60                                      'sqlite' => 'DBSQLite',
  61                                      '' => 'DBNone',
  62                                  );
  63  
  64      /**
  65       * Creates a new instance of the database adapter associated
  66       * with the specified Creole driver.
  67       *
  68       * @param string $driver The name of the Propel/Creole driver to
  69       * create a new adapter instance for or a shorter form adapter key.
  70       * @return DBAdapter An instance of a Propel database adapter.
  71       * @throws PropelException if the adapter could not be instantiated.
  72       */
  73      public static function factory($driver) {        
  74          $adapterClass = isset(self::$adapters[$driver]) ? self::$adapters[$driver] : null;
  75          if ($adapterClass !== null) {
  76              require_once 'propel/adapter/'.$adapterClass.'.php';
  77              $a = new $adapterClass();
  78              return $a;
  79          } else {
  80              throw new PropelException("Unsupported Propel driver: " . $driver . ": Check your configuration file");
  81          }
  82      }
  83  
  84      /**
  85       * This method is used to ignore case.
  86       *
  87       * @param in The string to transform to upper case.
  88       * @return string The upper case string.
  89       */
  90      public abstract function toUpperCase($in);
  91  
  92      /**
  93       * Returns the character used to indicate the beginning and end of
  94       * a piece of text used in a SQL statement (generally a single
  95       * quote).
  96       *
  97       * @return string The text delimeter.
  98       */
  99      public function getStringDelimiter()
 100      {
 101          return '\'';
 102      }
 103      
 104      /**
 105       * Locks the specified table.
 106       *
 107       * @param Connection $con The Creole connection to use.
 108       * @param string $table The name of the table to lock.
 109       * @return void
 110       * @throws SQLException No Statement could be created or executed.
 111       */
 112      public abstract function lockTable(Connection $con, $table);
 113  
 114      /**
 115       * Unlocks the specified table.
 116       *
 117       * @param Connection $con The Creole connection to use.
 118       * @param string $table The name of the table to unlock.
 119       * @return void
 120       * @throws SQLException No Statement could be created or executed.
 121       */
 122      public abstract function unlockTable(Connection $con, $table);
 123  
 124      /**
 125       * This method is used to ignore case.
 126       *
 127       * @param string $in The string whose case to ignore.
 128       * @return string The string in a case that can be ignored.
 129       */
 130      public abstract function ignoreCase($in);
 131  
 132      /**
 133       * This method is used to ignore case in an ORDER BY clause.
 134       * Usually it is the same as ignoreCase, but some databases
 135       * (Interbase for example) does not use the same SQL in ORDER BY
 136       * and other clauses.
 137       *
 138       * @param string $in The string whose case to ignore.
 139       * @return string The string in a case that can be ignored.
 140       */
 141      public function ignoreCaseInOrderBy($in)
 142      {
 143          return $this->ignoreCase($in);
 144      }      
 145  
 146      /**
 147       * Returns SQL which concatenates the second string to the first.
 148       *
 149       * @param string String to concatenate.
 150       * @param string String to append.
 151       * @return string 
 152       */
 153      public abstract function concatString($s1, $s2);
 154  
 155      /**
 156       * Returns SQL which extracts a substring.
 157       *
 158       * @param string String to extract from.
 159       * @param int Offset to start from.
 160       * @param int Number of characters to extract.
 161       * @return string 
 162       */
 163      public abstract function subString($s, $pos, $len);
 164  
 165      /**
 166       * Returns SQL which calculates the length (in chars) of a string.
 167       *
 168       * @param string String to calculate length of.
 169       * @return string 
 170       */
 171      public abstract function strLength($s);
 172      
 173      
 174      /**
 175       * Quotes database objec identifiers (table names, col names, sequences, etc.).
 176       * @param string $text The identifier to quote.
 177       * @return string The quoted identifier.
 178       */
 179  	public function quoteIdentifier($text)
 180      {
 181          return '"' . $text . '"';
 182      }
 183      
 184  }


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