Beanstalk队列错误[PDOException]找不到驱动程序。当保存数据库雄辩

时间:2016-04-08 10:19:33

标签: laravel queue beanstalkd pheanstalk

嘿伙计们我收到错误"错误[PDOException]找不到驱动程序"喜欢描述我的头衔。有谁知道如何解决它??

这是我的.env

APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:CZRXQSmW+gkqzEV0NzRZDtxmsUjoHdk3ZuYqkIh3rgw=
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=secret
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=beanstalkd

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

并且有我的代码

这个是队列一

namespace Automation\Jobs;

use Automation\Models\UserLog;
use Automation\Models\User;
use Automation\Jobs\Job;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;


class SendReminderEmail extends Job implements ShouldQueue
{
    use InteractsWithQueue, SerializesModels;

    protected $user;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($id)
    {

      $this->user = $id;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        echo "start";

        $userlog = new UserLog;
        $userlog->email = $this->user."@test.com";
        $userlog->admin = $this->user;
        $userlog->description = $this->user;
        $userlog->created = date("Y-m-d H:i:s");
        $userlog->save();

        $sleep = mt_rand(1, 10);
        sleep($sleep);

        $userlog = new UserLog;
        $userlog->email = $this->user."@test.com";
        $userlog->admin = $this->user;
        $userlog->description = $this->user;
        $userlog->created = date("Y-m-d H:i:s");
        $userlog->save();

        echo "end";
    }
}

我只是用这样的函数调用

$this->dispatch(new SendReminderEmail(7));

我在ubuntu服务器上工作,当我使用php artisan队列时出现错误:在命令行上监听

1 个答案:

答案 0 :(得分:0)

发生这种情况是因为我没有在linux上安装sql。 在linux终端:sudo apt-get install php5-mysql,那个问题消失了