public static function create($name, array $fields)
    {
        $fields = Helpers\Validate::arrToLower($fields);

        if (Helpers\Data::table($name)->exists() && Helpers\Config::table($name)->exists())
        {
            throw new LazerException('helper\Table "' . $name . '" already exists');
        }

        $types = array_values($fields);

        Helpers\Validate::types($types);

        if (!array_key_exists('id', $fields))
        {
            $fields = array('id' => 'integer') + $fields;
        }

        $data            = new \stdClass();
        $data->last_id   = 0;
        $data->schema    = $fields;
        $data->relations = new \stdClass();

        Helpers\Data::table($name)->put(array());
        Helpers\Config::table($name)->put($data);
    }
public static function create($name, array $fields)
    {
        $fields = Helpers\Validate::arrToLower($fields);

        if (Helpers\Data::table($name)->exists() && Helpers\Config::table($name)->exists())
        {
            throw new LazerException('helper\Table "' . $name . '" already exists');
        }

        $types = array_values($fields);

        Helpers\Validate::types($types);

        if (!array_key_exists('id', $fields))
        {
            $fields = array('id' => 'integer') + $fields;
        }

        $data            = new \stdClass();
        $data->last_id   = 0;
        $data->schema    = $fields;
        $data->relations = new \stdClass();

        Helpers\Data::table($name)->put(array());
        Helpers\Config::table($name)->put($data);
    }
public static function create ( $ name , array $ fields ) { $ fields = Helpers \ Validate :: arrToLower ( $ fields ) ; if ( Helpers \ Data :: table ( $ name ) -> exists ( ) && Helpers \ Config :: table ( $ name ) -> exists ( ) ) { throw new LazerException ( 'helper\Table "' . $ name . '" already exists' ) ; } $ types = array_values ( $ fields ) ; Helpers \ Validate :: types ( $ types ) ; if ( ! array_key_exists ( 'id' , $ fields ) ) { $ fields = array ( 'id' => 'integer' ) + $ fields ; } $ data = new \ stdClass ( ) ; $ data -> last_id = 0 ; $ data -> schema = $ fields ; $ data -> relations = new \ stdClass ( ) ; Helpers \ Data :: table ( $ name ) -> put ( array ( ) ) ; Helpers \ Config :: table ( $ name ) -> put ( $ data ) ; }
Creating new table

For example few fields:

Database::create('news', array(
'title' => 'string',
'content' => 'string',
'rating' => 'double',
'author' => 'integer'
));

Types of field:
- boolean
- integer
- string
- double (also for float type)

ID field isn't required (it will be created automatically) but you can specify it at first place.

@uses \Lazer\Classes\Helpers\Data::arrToLower() to lower case keys and values of array
@uses \Lazer\Classes\Helpers\Data::exists() to check if data file exists
@uses \Lazer\Classes\Helpers\Config::exists() to check if config file exists
@uses \Lazer\Classes\Helpers\Validate::types() to check if type of fields are correct
@uses \Lazer\Classes\Helpers\Data::put() to save data file
@uses \Lazer\Classes\Helpers\Config::put() to save config file
@param string $name Table name
@param array $fields Field configuration
@throws LazerException If table exist
Creating new table