Laravel 5 Laravel 5中排队命令中的查询生成器

Laravel 5 Laravel 5中排队命令中的查询生成器,laravel-5,queue,query-builder,Laravel 5,Queue,Query Builder,我正在使用Laravel 5.0,并使用Artisan CLI创建了一个排队命令: php artisan make:command SendEmail --queued 我需要在这个命令中使用DB::table query builder方法,但我无法使它工作 这是我的代码摘录: <?php namespace App\Commands; use App\Commands\Command; use DB; use Illuminate\Queue\SerializesModels;

我正在使用Laravel 5.0,并使用Artisan CLI创建了一个排队命令:

php artisan make:command SendEmail --queued
我需要在这个命令中使用DB::table query builder方法,但我无法使它工作

这是我的代码摘录:

<?php namespace App\Commands;

use App\Commands\Command;
use DB;

use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Bus\SelfHandling;
use Illuminate\Contracts\Queue\ShouldBeQueued;

class SendEmail extends Command implements SelfHandling, ShouldBeQueued {

use InteractsWithQueue, SerializesModels;

protected $message;

public function __construct($message)
{
    $this->message = $message;
}

public function handle()
{
    $data = DB::table('structures')->where('id', '=', '1')->first();
    // $data is always empty even if database connection works outside the command!!! <-------------------
    // no error exception is thrown
}

}

我做错了什么?

我发现了错误。我必须重新启动主管队列才能正确地重新读取代码:

supervisorctl
supervisor> restart myQueue