CSqliteColumnSchema.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * CSqliteColumnSchema class file.
  4. *
  5. * @author Qiang Xue <qiang.xue@gmail.com>
  6. * @link http://www.yiiframework.com/
  7. * @copyright 2008-2013 Yii Software LLC
  8. * @license http://www.yiiframework.com/license/
  9. */
  10. /**
  11. * CSqliteColumnSchema class describes the column meta data of a SQLite table.
  12. *
  13. * @author Qiang Xue <qiang.xue@gmail.com>
  14. * @package system.db.schema.sqlite
  15. * @since 1.0
  16. */
  17. class CSqliteColumnSchema extends CDbColumnSchema
  18. {
  19. /**
  20. * Extracts the default value for the column.
  21. * The value is typecasted to correct PHP type.
  22. * @param mixed $defaultValue the default value obtained from metadata
  23. */
  24. protected function extractDefault($defaultValue)
  25. {
  26. if($this->dbType==='timestamp' && $defaultValue==='CURRENT_TIMESTAMP')
  27. $this->defaultValue=null;
  28. else
  29. $this->defaultValue=$this->typecast(strcasecmp($defaultValue,'null') ? $defaultValue : null);
  30. if($this->type==='string' && $this->defaultValue!==null) // PHP 5.2.6 adds single quotes while 5.2.0 doesn't
  31. $this->defaultValue=trim($this->defaultValue,"'\"");
  32. }
  33. }