Php/fuelphp/migration/model crud
提供: 初心者エンジニアの簡易メモ
migrationを使ってmodelを作成する
php oil g model user name:varchar[31] email:string[63] password:string[31] msg:text created_at:datetime updated_at:datetime --crud
- fuel/app/classes/model/test.php
<?php class Model_Test extends \Model_Crud { protected static $_properties = array( 'id', 'name', 'created_at', 'updated_at' ); protected static $_table_name = 'tests'; }
- fuel/app/migrations/002_create_users.php
namespace Fuel\Migrations; class Create_users { public function up() { \DBUtil::create_table('users', array( 'id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true, 'unsigned' => true), 'name' => array('constraint' => 31, 'type' => 'varchar'), 'email' => array('constraint' => 63, 'type' => 'varchar'), 'password' => array('constraint' => 31, 'type' => 'varchar'), 'msg' => array('type' => 'text'), 'created_at' => array('type' => 'datetime'), 'updated_at' => array('type' => 'datetime'),
), array('id')); }
public function down() { \DBUtil::drop_table('users'); } }