简体   繁体   English

Laravel 4 - 在控制器中使用renameColumn

[英]Laravel 4 - Using renameColumn in controller

I want to use artisan migration within my controller, like this 我想在我的控制器中使用工匠迁移,就像这样

echo '<br>init migrate:install...';
Artisan::call('migrate');
echo 'done migrate:install';

It works fine for all my table creations and etc. But there are problems when I try to use $table->renameColumn 它适用于我的所有表创建等。但是当我尝试使用$ table-> renameColumn时会出现问题

Laravel doc said I need to include doctrine/dbal, but how? Laravel医生说我需要包含教义/ dbal,但是如何? I have tried use Doctrine\\DBAL\\Driver\\PDOMySql\\Driver; 我试过use Doctrine\\DBAL\\Driver\\PDOMySql\\Driver; but no luck. 但没有运气。

FYI i cannot use CLI, my host doesn't provide any CLI to me. 仅供参考我无法使用CLI,我的主机不向我提供任何CLI。

Here is my error 这是我的错误

Symfony \ Component \ Debug \ Exception \ FatalErrorException
Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found

UPDATE UPDATE

Same error when using terminal to migrate 使用终端迁移时出现相同的错误

SECOND UPDATE 第二次更新

An Example of migration code at app/database/migrations app / database / migrations中的迁移代码示例

use Illuminate\Database\Migrations\Migration;

class UpdatePostsTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('user', function($table)
        {
            $table->renameColumn('fullname', 'full_name');
        });
    }
}

Add the doctrine/dbal dependency to your composer.json file. doctrine/dbal依赖项添加到composer.json文件中。

For more information, it's on the very bottom of this page in the documentation. 有关详细信息,请参阅本文档的最底部。

http://laravel.com/docs/releases http://laravel.com/docs/releases

Add doctrine/dbal dependency to your composer.json file, like doctrine / dbal依赖项添加到您的composer.json文件中,例如

"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.1.*",
    "illuminate/html": "5.*",
    "doctrine/dbal": "~2.3"
},

Then update composer using sudo composer update command, this will work. 然后使用sudo composer update命令更新composer,这将有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM