/** * Extracts the default value for the column. * The value is typecasted to correct PHP type. * * @param mixed $defaultValue the default value obtained from metadata */ public function extractDefault($defaultValue) { if ('autoincrement' === $defaultValue) { $this->defaultValue = null; $this->autoIncrement = true; } elseif ($defaultValue == '(NULL)') { $this->defaultValue = null; } elseif ($this->type === static::TYPE_BOOLEAN) { if ('1' === $defaultValue) { $this->defaultValue = true; } elseif ('0' === $defaultValue) { $this->defaultValue = false; } else { $this->defaultValue = null; } } elseif ($this->type === static::TYPE_TIMESTAMP) { $this->defaultValue = null; if ($defaultValue === 'current timestamp') { $this->defaultValue = ['expression' => 'CURRENT TIMESTAMP']; $this->type = static::TYPE_TIMESTAMP_ON_CREATE; } elseif ($defaultValue === 'timestamp') { $this->defaultValue = ['expression' => 'TIMESTAMP']; $this->type = static::TYPE_TIMESTAMP_ON_UPDATE; } } else { parent::extractDefault(str_replace(['(', ')', "'"], '', $defaultValue)); } }
/** * Extracts the default value for the column. * The value is typecasted to correct PHP type. * * @param mixed $defaultValue the default value obtained from metadata */ public function extractDefault($defaultValue) { if ('autoincrement' === $defaultValue) { $this->defaultValue = null; $this->autoIncrement = true; } elseif ($defaultValue == '(NULL)') { $this->defaultValue = null; } elseif ($this->type === 'boolean') { if ('1' === $defaultValue) { $this->defaultValue = true; } elseif ('0' === $defaultValue) { $this->defaultValue = false; } else { $this->defaultValue = null; } } elseif ($this->type === 'timestamp') { $this->defaultValue = null; if ($defaultValue === 'current timestamp') { $this->defaultValue = ['expression' => 'CURRENT TIMESTAMP']; $this->type = 'timestamp_on_create'; } elseif ($defaultValue === 'timestamp') { $this->defaultValue = ['expression' => 'TIMESTAMP']; $this->type = 'timestamp_on_update'; } } else { parent::extractDefault(str_replace(['(', ')', "'"], '', $defaultValue)); } }
/** * Extracts the default value for the column. * The value is typecasted to correct PHP type. * * @param mixed $defaultValue the default value obtained from metadata */ public function extractDefault($defaultValue) { if (strncmp($this->dbType, 'bit', 3) === 0) { $this->defaultValue = bindec(trim($defaultValue, 'b\'')); } else { parent::extractDefault($defaultValue); } }
/** * Extracts the default value for the column. * The value is typecasted to correct PHP type. * * @param mixed $defaultValue the default value obtained from metadata */ public function extractDefault($defaultValue) { if (stripos($defaultValue, 'timestamp') !== false) { $this->defaultValue = null; } else { parent::extractDefault($defaultValue); } }
/** * Extracts the default value for the column. * The value is typecasted to correct PHP type. * * @param mixed $defaultValue the default value obtained from metadata */ public function extractDefault($defaultValue) { if ($defaultValue == '(NULL)') { $this->defaultValue = null; } elseif ($this->type === static::TYPE_BOOLEAN) { if ('((1))' === $defaultValue) { $this->defaultValue = true; } elseif ('((0))' === $defaultValue) { $this->defaultValue = false; } else { $this->defaultValue = null; } } elseif ($this->type === static::TYPE_TIMESTAMP) { $this->defaultValue = null; } else { parent::extractDefault(str_replace(array('(', ')', "'"), '', $defaultValue)); } }
/** * Extracts the default value for the column. * The value is typecasted to correct PHP type. * * @param mixed $defaultValue the default value obtained from metadata */ public function extractDefault($defaultValue) { if ($defaultValue == '(NULL)') { $this->defaultValue = null; } elseif ($this->type === 'boolean') { if ('((1))' === $defaultValue) { $this->defaultValue = true; } elseif ('((0))' === $defaultValue) { $this->defaultValue = false; } else { $this->defaultValue = null; } } elseif ($this->type === 'timestamp') { $this->defaultValue = null; } else { parent::extractDefault(str_replace(array('(', ')', "'"), '', $defaultValue)); } }