Esempio n. 1
0
 protected function getType(Column $column)
 {
     $type = 0;
     if ($column->getLength() > 0) {
         $type += $column->getLength();
     }
     $type = $type | SerializeTrait::getTypeByDoctrineType($column->getType());
     if (!$column->getNotnull()) {
         $type = $type | TableInterface::IS_NULL;
     }
     if ($column->getAutoincrement()) {
         $type = $type | TableInterface::AUTO_INCREMENT;
     }
     return $type;
 }
Esempio n. 2
0
    protected function convertDoctrineTypeToString(Column $column, $isPrimary)
    {
        $type = SerializeTrait::getTypeByDoctrineType($column->getType());
        $name = $column->getName();
        switch ($type) {
            case TableInterface::TYPE_BIGINT:
                $result = <<<PHP
\t\t\t'{$name}' => self::TYPE_BIGINT
PHP;
                break;
            case TableInterface::TYPE_BLOB:
                $result = <<<PHP
\t\t\t'{$name}' => self::TYPE_BLOB
PHP;
                break;
            case TableInterface::TYPE_BOOLEAN:
                $result = <<<PHP
\t\t\t'{$name}' => self::TYPE_BOOLEAN
PHP;
                break;
            case TableInterface::TYPE_DATETIME:
                $result = <<<PHP
\t\t\t'{$name}' => self::TYPE_DATETIME
PHP;
                break;
            case TableInterface::TYPE_DATE:
                $result = <<<PHP
\t\t\t'{$name}' => self::TYPE_DATE
PHP;
                break;
            case TableInterface::TYPE_DECIMAL:
                $result = <<<PHP
\t\t\t'{$name}' => self::TYPE_DECIMAL
PHP;
                break;
            case TableInterface::TYPE_FLOAT:
                $result = <<<PHP
\t\t\t'{$name}' => self::TYPE_FLOAT
PHP;
                break;
            case TableInterface::TYPE_INT:
                $result = <<<PHP
\t\t\t'{$name}' => self::TYPE_INT
PHP;
                break;
            case TableInterface::TYPE_SMALLINT:
                $result = <<<PHP
\t\t\t'{$name}' => self::TYPE_SMALLINT
PHP;
                break;
            case TableInterface::TYPE_TEXT:
                $result = <<<PHP
\t\t\t'{$name}' => self::TYPE_TEXT
PHP;
                break;
            case TableInterface::TYPE_ARRAY:
                $result = <<<PHP
\t\t\t'{$name}' => self::TYPE_ARRAY
PHP;
                break;
            case TableInterface::TYPE_OBJECT:
                $result = <<<PHP
\t\t\t'{$name}' => self::TYPE_OBJECT
PHP;
                break;
            case TableInterface::TYPE_TIME:
                $result = <<<PHP
\t\t\t'{$name}' => self::TYPE_TIME
PHP;
                break;
            case TableInterface::TYPE_VARCHAR:
            default:
                $result = <<<PHP
\t\t\t'{$name}' => self::TYPE_VARCHAR
PHP;
                break;
        }
        if ($column->getAutoincrement()) {
            $result .= ' | self::AUTO_INCREMENT';
        }
        if ($isPrimary) {
            $result .= ' | self::PRIMARY_KEY';
        }
        return $result . ',';
    }