简体   繁体   中英

laravel cannot find driver (after completing migrations)

This is not the usual "cannot find driver" error message with Laravel. I am able to successfully create migrations and see them reflected in the database. However when I attempt to insert or select, i get the following error:

 QueryException in Connection.php line 647:
could not find driver (SQL: insert into .....

this is from my migration file:

public function up()
    {
        Schema::create('vendors', function (Blueprint $table) {
             $table->increments('id');
            $table->string('vendor_name');
            $table->string('contact_name');
            $table->string('phone_number');
            $table->string('alt_phone_number');P
            $table->string('email')->unique();
            $table->string('address');
            $table->timestamps();
        });
    }

and this is from my store() method in my RESTful Model:

public function store(Request $request)
    {
        //
        Vendor::create(request(['vendor_name', 'contact_name', 'phone_number', 'alt_phone_number', 'email','address']));
        this.index();
    }

I know the request is getting the data, as I am about to do a dd() and view the contents perfectly fine.

This worked for me:
For PDOException: could not find driver for MySQL, and if it is Debian based OS,

sudo apt-get -y install php5-mysql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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