Warm tip: This article is reproduced from stackoverflow.com, please click
driver laravel limit mysql php

Laravel Exception could not find driver SQ limit 1

发布于 2020-04-22 10:12:23

i was learning laravel6 from scratch from laracast.com and when i started to use the database. I bumped into the following problem:

Illuminate\Database\QueryException could not find driver (SQL: select * from posts where slug = my-first-post limit 1)

I use wamp with phpmyadmin. I tried xamp and mySQL workbench. I updated my dependencies, but without result.

this is my controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PostsController extends Controller
{
    public function show($slug)
    {
        $post = \DB::table('posts')->where('slug', $slug)->first();

        if(! $post){
            abort(404);
        }

     return view('post', [
         'post' => $post
     ]);
    }
}

Can somebody please help me with this problem?

Best regards, Jeff

Questioner
Jeffrey van der Kruit
Viewed
56
Jeffrey van der Kruit 2020-02-07 19:14

When i installed composer. I needed to assign the location of my php.exe. This field was empty so i installed php when i already had wampp installed.

Solution: I uninstalled wampp, composer and deleted php. I started over and installed xampp first. When i wanted to install composer. It immediately suggested php.exe in my xampp folder. After installing laravel the problem was solved.

Conclusion: Composer installation went wrong. Since i had multiple php's in my system i probably assignt composer to the wrong one.

Thanks for your help.