Esempio n. 1
0
    {
    }
}
abstract class Migration
{
    function createTable($name, $columnsClosure)
    {
        $table = new Db_Table($name);
        $columnsClosure($table);
    }
}
class CreateUser extends Migration
{
    public function up()
    {
        $this->createTable('users', function ($t) {
            $t->string('name');
            $t->string('email');
            $t->boolean('is_active');
        });
    }
    public function down()
    {
        $this->dropTable('users');
    }
}
$m = new CreateUser();
echo "'users' table created\n";
$m->up();
echo "'users' table dropped\n";
$m->down();
 public function actionUpdateKeys()
 {
     if (Yii::app()->request->isAjaxRequest) {
         $model = new CreateUser('updateKeys');
         $model->attributes = $_POST;
         if ($model->validate()) {
             $model->updateKeys(Yii::app()->user->getId());
         } else {
             echo json_encode($model->getErrors());
         }
     }
 }