2

私はlaravel 5.2バージョンとPHP 7.1を使用しています。以下に示すように、列の存在を確認するコードがあるlaravelプロジェクトからファイルを移行しようとしています-

if (!Schema::hasColumn('table1', 'column1')) {
    // Add column1
}

私はコードが完全に問題ないことを知っており、これは同じコードをセットアップしている間にすでに数回機能しています。しかし、今私は別のマシンでこれを試していますが、エラーで失敗します -

[ErrorException]
未定義のプロパティ: stdClass::$column_name

コードから hasColumn チェックを削除すると、このエラーを取り除くことができますが、これはコード全体に記述したものであり、移行を実行するためだけにすべての移行を変更することはできません。

これに関するヘルプは大歓迎です。

スタックトレース:

[ErrorException]
未定義のプロパティ: stdClass::$column_name

例外トレース: () at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php:18 Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php:18 で Illuminate\Database\Query\Processors\MySqlProcessor->Illuminate\Database\Query\ Processors{closure}() at n/a:n/a array_map() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php:21 Illuminate\Database\Query\Processors\MySqlProcessor->processColumnListing() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php:40 Illuminate\Database\Schema \MySqlBuilder->getColumnListing() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:69 Illuminate\Database\Schema\Builder->hasColumn() at /private/ var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:217 Illuminate\Support\Facades\Facade::__callStatic() at /private/var/www/html/whitelabel_eb /database/migrations/2017_07_28_053158_add_columns_to_project_configurations_table.php:16 AddColumnsToProjectConfigurationsTable->{closure}() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:69 照らす\Database\Schema\Blueprint->__construct() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:207 Illuminate\Database\Schema\Builder- >createBlueprint() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:116 Illuminate\Database\Schema\Builder->table() at /private/ var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:217 Illuminate\Support\Facades\Facade::__callStatic() at /private/var/www/html/whitelabel_eb /database/migrations/2017_07_28_053158_add_columns_to_project_configurations_table.php:103 AddColumnsToProjectConfigurationsTable->up() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:135 Illuminate\Database \Migrations\Migrator->runUp() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:112 Illuminate\Database\Migrations\Migrator->runMigrationList() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:85 Illuminate\Database\Migrations\ Migrator->run() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:74 Illuminate\Database\Console\Migrations\MigrateCommand-> fire() at n/a:n/a call_user_func_array() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Container/Container.php:507 Illuminate\Container\Container-> call() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Console/Command.php:150 Illuminate\Console\Command->execute() at /private/var/www/ html/whitelabel_eb/vendor/symfony/console/Command/Command.php:238 Symfony\Component\Console\Command\Command->run() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Console/Command.php:136 Illuminate\Console\Command- >run() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:840 Symfony\Component\Console\Application->doRunCommand() at /private/var/www/html/whitelabel_eb /vendor/symfony/console/Application.php:190 Symfony\Component\Console\Application->doRun() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:114 Symfony\Component \Console\Application->run() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107 Illuminate\Foundation\Console\Kernel->handle () /private/var/www/html/whitelabel_eb/artisan:353535run() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Console/Command.php:136 Illuminate\Console\Command->run() at /private/var/www/ html/whitelabel_eb/vendor/symfony/console/Application.php:840 Symfony\Component\Console\Application->doRunCommand() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:190 Symfony\Component\Console\Application->doRun() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:114 Symfony\Component\Console\Application->run() at /private /var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107 Illuminate\Foundation\Console\Kernel->handle() at /private/var/www/html/ whitelabel_eb/職人:35run() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Console/Command.php:136 Illuminate\Console\Command->run() at /private/var/www/ html/whitelabel_eb/vendor/symfony/console/Application.php:840 Symfony\Component\Console\Application->doRunCommand() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:190 Symfony\Component\Console\Application->doRun() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:114 Symfony\Component\Console\Application->run() at /private /var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107 Illuminate\Foundation\Console\Kernel->handle() at /private/var/www/html/ whitelabel_eb/職人:353535run() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:840 Symfony\Component\Console\Application->doRunCommand() at /private/var/www/html/whitelabel_eb/ vendor/symfony/console/Application.php:190 Symfony\Component\Console\Application->doRun() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:114 Symfony\Component\ Console\Application->run() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107 Illuminate\Foundation\Console\Kernel->handle( ) /private/var/www/html/whitelabel_eb/artisan:35run() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:840 Symfony\Component\Console\Application->doRunCommand() at /private/var/www/html/whitelabel_eb/ vendor/symfony/console/Application.php:190 Symfony\Component\Console\Application->doRun() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:114 Symfony\Component\ Console\Application->run() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107 Illuminate\Foundation\Console\Kernel->handle( ) /private/var/www/html/whitelabel_eb/artisan:35190 Symfony\Component\Console\Application->doRun() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:114 Symfony\Component\Console\Application->run() at / private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107 Illuminate\Foundation\Console\Kernel->handle() at /private/var/www/html /whitelabel_eb/artisan:35190 Symfony\Component\Console\Application->doRun() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:114 Symfony\Component\Console\Application->run() at / private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107 Illuminate\Foundation\Console\Kernel->handle() at /private/var/www/html /whitelabel_eb/artisan:35

4

2 に答える 2

3

この問題を解決するために、次の変更を行いました。次のパスに移動します。/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php

これを return $r->column_name; 行番号18に 変更しますreturn $r->COLUMN_NAME;

于 2019-11-21T14:08:40.317 に答える