Ejemplo n.º 1
0
 /**
  * Extracts the default value for the column.
  * The value is typecasted to correct PHP type.
  * @param mixed $defaultValue the default value obtained from metadata
  */
 protected function extractDefault($defaultValue)
 {
     if (stripos($defaultValue, 'timestamp') !== false) {
         $this->defaultValue = null;
     } else {
         parent::extractDefault($defaultValue);
     }
 }
Ejemplo n.º 2
0
 /**
  * Converts the input value to the type that this column is of.
  * @param mixed $value input value
  * @return mixed converted value
  */
 public function typecast($value)
 {
     if ($this->type === 'boolean') {
         return $value ? 1 : 0;
     } else {
         return parent::typecast($value);
     }
 }
Ejemplo n.º 3
0
 protected function extractDefault($defaultValue)
 {
     if ($this->dbType === 'timestamp') {
         $this->defaultValue = null;
     } else {
         parent::extractDefault(str_replace(array('(', ')', "'"), '', $defaultValue));
     }
 }
Ejemplo n.º 4
0
 /**
  * Extracts the default value for the column.
  * The value is typecasted to correct PHP type.
  * @param mixed $defaultValue the default value obtained from metadata
  */
 protected function extractDefault($defaultValue)
 {
     if ($this->dbType === 'TIMESTAMP' && $defaultValue === 'CURRENT_TIMESTAMP') {
         $this->defaultValue = null;
     } else {
         parent::extractDefault($defaultValue);
     }
 }
Ejemplo n.º 5
0
 /**
  * Extracts size, precision and scale information from column's DB type.
  * @param string $dbType the column's DB type
  */
 protected function extractLimit($dbType)
 {
     if (strncmp($dbType, 'enum', 4) === 0 && preg_match('/\\((.*)\\)/', $dbType, $matches)) {
         $values = explode(',', $matches[1]);
         $size = 0;
         foreach ($values as $value) {
             if (($n = strlen($value)) > $size) {
                 $size = $n;
             }
         }
         $this->size = $this->precision = $size - 2;
     } else {
         parent::extractLimit($dbType);
     }
 }
 /**
  * Extracts the default value for the column.
  * The value is typecasted to correct PHP type.
  * @param mixed the default value obtained from metadata
  */
 protected function extractDefault($defaultValue)
 {
     /*
      * handle CURRENT_DATE/TIME/TIMESTAMP with optional precision
      * @todo handle context variable 'NOW'
      * ref. http://www.firebirdsql.org/refdocs/langrefupd25-variables.html
      */
     if (preg_match('/(CURRENT_|NULL|TODAY|TOMORROW|YESTERDAY)/i', $defaultValue)) {
         $this->defaultValue = null;
     } elseif ($defaultValue == "''") {
         $this->defaultValue = '';
     } else {
         parent::extractDefault($defaultValue);
     }
 }
Ejemplo n.º 7
0
 /**
  * Extracts size, precision and scale information from column's DB type.
  * @param string $dbType the column's DB type
  */
 protected function extractLimit($dbType)
 {
     if (strncmp($dbType, 'enum', 4) === 0 && preg_match('/\\(([\'"])(.*)\\1\\)/', $dbType, $matches)) {
         // explode by (single or double) quote and comma (ENUM values may contain commas)
         $values = explode($matches[1] . ',' . $matches[1], $matches[2]);
         $size = 0;
         foreach ($values as $value) {
             if (($n = strlen($value)) > $size) {
                 $size = $n;
             }
         }
         $this->size = $this->precision = $size;
     } else {
         parent::extractLimit($dbType);
     }
 }