[ Index ]
 

Code source de Symfony 1.0.0

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

title

Body

[fermer]

/lib/vendor/propel-generator/classes/propel/engine/platform/ -> DefaultPlatform.php (source)

   1  <?php
   2  /*
   3   *  $Id: DefaultPlatform.php 137 2005-11-17 14:11:19Z fabien $
   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://propel.phpdb.org>.
  20   */
  21   
  22  require_once 'propel/engine/platform/Platform.php';
  23  include_once 'propel/engine/database/model/Domain.php';
  24  
  25  /**
  26   * Default implementation for the Platform interface.
  27   *
  28   * @author Martin Poeschl <mpoeschl@marmot.at> (Torque)
  29   * @version $Revision: 258 $
  30   * @package propel.engine.platform
  31   */
  32  class DefaultPlatform implements Platform {
  33  
  34      private $schemaDomainMap;
  35      
  36      /**
  37       * Default constructor.
  38       */
  39      public function __construct() 
  40      {
  41          $this->initialize();
  42      }
  43      
  44      protected function initialize()
  45      {
  46          $this->schemaDomainMap = array();
  47          foreach(PropelTypes::getPropelTypes() as $type) {
  48              $this->schemaDomainMap[$type] = new Domain($type);
  49          }
  50          $this->schemaDomainMap[PropelTypes::BU_DATE] = new Domain("DATE");
  51          $this->schemaDomainMap[PropelTypes::BU_TIMESTAMP] = new Domain("TIMESTAMP");
  52          $this->schemaDomainMap[PropelTypes::BOOLEAN] = new Domain("INTEGER");
  53      }
  54      
  55      protected function setSchemaDomainMapping(Domain $domain) 
  56      {
  57          $this->schemaDomainMap[$domain->getType()] = $domain;
  58      }
  59      
  60      /**
  61       * Returns the short name of the database type that this platform represents.
  62       * For example MysqlPlatform->getDatabaseType() returns 'mysql'.
  63       * @return string
  64       */
  65  	public function getDatabaseType()
  66      {
  67          $clazz = get_class($this);
  68          $pos = strpos($clazz, 'Platform');
  69          return strtolower(substr($clazz,0,$pos));
  70      }
  71      
  72      /**
  73       * @see Platform::getMaxColumnNameLength()
  74       */
  75      public function getMaxColumnNameLength()
  76      {
  77          return 64;
  78      }
  79  
  80      /**
  81       * @see Platform::getNativeIdMethod()
  82       */
  83      public function getNativeIdMethod()
  84      {
  85          return Platform::IDENTITY;
  86      }
  87  
  88      /**
  89       * @see Platform::getDomainForType()
  90       */
  91      public function getDomainForType($propelType) 
  92      {
  93          if (!isset($this->schemaDomainMap[$propelType])) {
  94              throw new EngineException("Cannot map unknown Propel type " . var_export($propelType, true) . " to native database type.");
  95          }
  96          return $this->schemaDomainMap[$propelType];
  97      }
  98  
  99      /**
 100       * @return Only produces a SQL fragment if null values are
 101       * disallowed.
 102       * @see Platform::getNullString(boolean)
 103       */
 104      public function getNullString($notNull)
 105      {
 106          // TODO: Check whether this is true for all DBs.  Also verify
 107          // the old Sybase templates.
 108          return ($notNull ? "NOT NULL" : "");
 109      }
 110  
 111      /**
 112       * @see Platform::getAutoIncrement()
 113       */
 114      public function getAutoIncrement()
 115      {
 116          return "IDENTITY";
 117      }
 118  
 119      /**
 120       * @see Platform::hasScale(String)
 121       * TODO collect info for all platforms
 122       */
 123      public function hasScale($sqlType)
 124      {
 125          return true;
 126      }
 127  
 128      /**
 129       * @see Platform::hasSize(String)
 130       * TODO collect info for all platforms
 131       */
 132      public function hasSize($sqlType)
 133      {
 134          return true;
 135      }
 136  
 137      /**
 138       * @see Platform::escapeText()
 139       */ 
 140      public function escapeText($text)
 141      {
 142          return str_replace("'", "''", $text);
 143      }
 144      
 145      /**
 146       * @see Platform::quoteIdentifier()
 147       */
 148  	public function quoteIdentifier($text)
 149      {
 150          return '"' . $text . '"';
 151      }
 152      
 153      /**
 154       * @see Platform::supportsNativeDeleteTrigger()
 155       */
 156      public function supportsNativeDeleteTrigger()
 157      {
 158          return false;
 159      }
 160      
 161      /**
 162       * @see Platform::getBooleanString()
 163       */
 164      public function getBooleanString($b)
 165      {
 166          $b = ($b === true || strtolower($b) === 'true' || $b === 1 || $b === '1' || strtolower($b) === 'y' || strtolower($b) === 'yes');
 167          return ($b ? '1' : '0');
 168      }
 169  }


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