shankarbala33/php_migration

PHP代码片段集合

0.9 2017-01-16 06:45 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:36:39 UTC


README

一个简单的PHP数据库迁移包,无任何依赖。

Packagist Release Wordpresss License

用于Wordpress迁移

include_once('/wordpress/migration.php');

$my_table_schema =  [
          'student_meta' => [
             'id' => [                  // Result : "id int(20) auto_increment primary key"
                 'key' => [
                     'auto_increment',
                     'primary key'
                 ],
                 'type' => 'int',
                 'limit' => 20
             ],
             'name' => [                // Result : "name varchar(255) unique key"
                 'key' => [
                     'unique key'
                 ],
                 'type' => 'varchar',
                 'limit' => 255
             ],
             'value' => [               // Result : "value longtext"
                 'key' => [],
                 'type' => 'longtext',
                 'limit' => ''
             ],
              '__table_property' => [    // For Table Properties.
                'ENGINE' => 'InnoDB'
            ]
           ]
          ];

用于核心PHP

  $my_table_schema = [
        'student' => [
            'student_id' => 'integer',
            'name' => 'string',
            'class' => 'string',
            'dob'  => 'data',
            'age' => 'integer'
        ],
        'class' => [
            'class_id' => 'integer',
            'student_id' => 'integer',
            'section' => 'string'
        ]
     ];

最终

$table_schema = "YOUR_TABLE_SCHEMA" ($my_table_schema)

// Trigger Migration.
ST_DATABASE::migrate($table_schema);     // It's Generate Formatted MySQL Query and Execute.

它将创建具有给定属性的 StudentClass 表。

许可

MIT许可证 © Shankar Thiyagaraajan