src/WPametu/DB/Column.php
private static function data_type($column){
        /** @var $wpdb \wpdb */
        global $wpdb;
        // Let's create query
        $sql = $column['type'];
        // Is DECIMAL?
        if( self::DECIMAL == $column['type'] ){
            $sql .= sprintf('(%d, %d)', $column['max_digit'], $column['float']);
        }
        // Add length
        if( isset($column['length']) ){
            $sql .= sprintf('(%d)', $column['length']);
        }
        // Is enum or set?
        if( self::is_set($column['type']) ){
            $values = [];
            foreach($column['values'] as $val){
                $values[] = $wpdb->prepare('%s', $val);
            }
            $sql .= sprintf('(%s)', implode(', ', $values));
        }
        // Is unsigned?
        if( self::is_numeric($column['type']) && isset($column['signed']) && !$column['signed'] ){
            $sql .= ' UNSIGNED';
        }
        // Is not null?
        if( !$column['null'] ){
            $sql .= ' NOT NULL';
        }
        // Is auto increment?
        if( isset($column['auto_increment']) && $column['auto_increment'] ){
            $sql .= ' AUTO_INCREMENT';
        }
        // Is primary key?
        if( isset($column['primary']) && $column['primary'] ){
            $sql .= ' PRIMARY KEY';
        }
        // Has default?
        if( isset($column['default']) ){
            if( self::is_numeric($column['default']) ){
                $repl = ' DEFAULT '.$column['default'];
            }else{
	            switch( $column['default'] ){
		            case 'CURRENT_TIMESTAMP':
						// Without replace
						$sql .= " DEFAULT {$column['default']}";
			            break;
		            default:
						// Replace
		                $sql .= $wpdb->prepare(' DEFAULT %s', $column['default']);
			            break;
	            }
            }
        }
        return $sql;
    }
private static function data_type($column){
        /** @var $wpdb \wpdb */
        global $wpdb;
        // Let's create query
        $sql = $column['type'];
        // Is DECIMAL?
        if( self::DECIMAL == $column['type'] ){
            $sql .= sprintf('(%d, %d)', $column['max_digit'], $column['float']);
        }
        // Add length
        if( isset($column['length']) ){
            $sql .= sprintf('(%d)', $column['length']);
        }
        // Is enum or set?
        if( self::is_set($column['type']) ){
            $values = [];
            foreach($column['values'] as $val){
                $values[] = $wpdb->prepare('%s', $val);
            }
            $sql .= sprintf('(%s)', implode(', ', $values));
        }
        // Is unsigned?
        if( self::is_numeric($column['type']) && isset($column['signed']) && !$column['signed'] ){
            $sql .= ' UNSIGNED';
        }
        // Is not null?
        if( !$column['null'] ){
            $sql .= ' NOT NULL';
        }
        // Is auto increment?
        if( isset($column['auto_increment']) && $column['auto_increment'] ){
            $sql .= ' AUTO_INCREMENT';
        }
        // Is primary key?
        if( isset($column['primary']) && $column['primary'] ){
            $sql .= ' PRIMARY KEY';
        }
        // Has default?
        if( isset($column['default']) ){
            if( self::is_numeric($column['default']) ){
                $repl = ' DEFAULT '.$column['default'];
            }else{
	            switch( $column['default'] ){
		            case 'CURRENT_TIMESTAMP':
						// Without replace
						$sql .= " DEFAULT {$column['default']}";
			            break;
		            default:
						// Replace
		                $sql .= $wpdb->prepare(' DEFAULT %s', $column['default']);
			            break;
	            }
            }
        }
        return $sql;
    }
private static function data_type ( $ column ) { /** @var $wpdb \wpdb */ global $ wpdb ; // Let's create query $ sql = $ column [ 'type' ] ; // Is DECIMAL? if ( self :: DECIMAL == $ column [ 'type' ] ) { $ sql .= sprintf ( '(%d, %d)' , $ column [ 'max_digit' ] , $ column [ 'float' ] ) ; } // Add length if ( isset ( $ column [ 'length' ] ) ) { $ sql .= sprintf ( '(%d)' , $ column [ 'length' ] ) ; } // Is enum or set? if ( self :: is_set ( $ column [ 'type' ] ) ) { $ values = [ ] ; foreach ( $ column [ 'values' ] as $ val ) { $ values [ ] = $ wpdb -> prepare ( '%s' , $ val ) ; } $ sql .= sprintf ( '(%s)' , implode ( ', ' , $ values ) ) ; } // Is unsigned? if ( self :: is_numeric ( $ column [ 'type' ] ) && isset ( $ column [ 'signed' ] ) && ! $ column [ 'signed' ] ) { $ sql .= ' UNSIGNED' ; } // Is not null? if ( ! $ column [ 'null' ] ) { $ sql .= ' NOT NULL' ; } // Is auto increment? if ( isset ( $ column [ 'auto_increment' ] ) && $ column [ 'auto_increment' ] ) { $ sql .= ' AUTO_INCREMENT' ; } // Is primary key? if ( isset ( $ column [ 'primary' ] ) && $ column [ 'primary' ] ) { $ sql .= ' PRIMARY KEY' ; } // Has default? if ( isset ( $ column [ 'default' ] ) ) { if ( self :: is_numeric ( $ column [ 'default' ] ) ) { $ repl = ' DEFAULT ' . $ column [ 'default' ] ; } else { switch ( $ column [ 'default' ] ) { case 'CURRENT_TIMESTAMP' : // Without replace $ sql .= " DEFAULT {$column['default']}" ; break ; default : // Replace $ sql .= $ wpdb -> prepare ( ' DEFAULT %s' , $ column [ 'default' ] ) ; break ; } } } return $ sql ; }
Build data type on create statement

@param array $column
@return string
Build data type on create statement