-2

I am getting this error

could not find driver (SQL: select user_id... ]

I've looked at other related questions and tried the suggestions but I am still getting the same error.

My PHP.ini has extension=php_pdo_mysql.dll

I've added "doctrine/dbal": "^2.5",

I've also tried clearing cache, config, dump auto load etc.

phpinfo() shows there are no PDO drivers.

Previously my phpstorm was pointing at a PHP installation that didn't have extension=php_pdo_mysql.dll enabled but I am still getting the same error even after pointing it to the correct PHP folder.

Sayed Mohd Ali
  • 2,156
  • 3
  • 12
  • 28
124697
  • 22,097
  • 68
  • 188
  • 315
  • 1
    Are you... trying to run a query in a `connect` call ? Show us the code that is generating this error. – GMB Jan 03 '19 at 12:34
  • 1
    `phpinfo() shows there are no PDO drivers.` you need configure your PHP interpreter with PDO driver – Artem Ilchenko Jan 03 '19 at 12:39
  • You should also show us your code that generates this error. It looks pretty strange that it complains about the driver and shows a select query. If you don't have the driver, the error would occur on connection, before you're making any queries. – M. Eriksson Jan 03 '19 at 12:47
  • there is no data in the implode you must be using implode inside SQL Query and the implode data must be empty. – Sayed Mohd Ali Jan 03 '19 at 12:50
  • Did you restart the server? – nice_dev Jan 03 '19 at 13:52
  • 1
    After being a member for 8 years and have 8k in rep, you should know [how to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) and [how do I ask a good question](http://stackoverflow.com/help/how-to-ask). Without the code that causes this, we will have _no idea_ what happens and why. – M. Eriksson Jan 03 '19 at 14:25

1 Answers1

0

You need to install PDO drivers first and if it did not solve your problem then below is the issue I have faced before maybe that will help.

sudo apt-get install php5.6-mysql/php7.2-mysql

You also can search for other database systems.

You also can search for the driver:

sudo apt-cache search drivername

Then Run the cmd php artisan migrate

You can also try:

sudo apt-get install php-sqlite3

also check the path for php-cli

If you can, run :

composer update

composer require doctrine/dbal

It looks like you have a missing dependency

Edit:

You might need to comment out the following in your php.ini file.

;extension=pdo_mysql.so

Taken from this post: Laravel 5 PDOException Could Not Find Driver . I think I had to do something exactly like this when setting up laravel on digital ocean.

There must be Query like this one in the code implode inside SQL code. check the variable $mistakeIdArr should not be empty.

 $sql = "Select * from `mistake` where `id` in (".implode(',',$mistakeIdArr).")";

I have also checked in my code the PDO is enabled or not

if (extension_loaded('pdo')) { echo "pdo enable";die; }else{ echo "not enable";die;}
Sayed Mohd Ali
  • 2,156
  • 3
  • 12
  • 28
  • How would a query be able to generate a _"could not find driver"_ error? – M. Eriksson Jan 03 '19 at 12:56
  • It happened to me that is why I am sharing the solution. because of that implode in the query part. – Sayed Mohd Ali Jan 03 '19 at 12:58
  • 1
    That would most likely not give you that error. AFAIK, "could not find driver" is an error that occurs when you're trying to connect to a database without having the driver installed. That's way before you make any queries. There isn't enough information in the question for us to be able to write an answer that's anything but a wild guess. – M. Eriksson Jan 03 '19 at 12:59
  • I know that but it also comes because of imploding later on. – Sayed Mohd Ali Jan 03 '19 at 13:01
  • I'm not saying you're incorrect, but out of curiosity, can you give a simple example of a query that would give that specific error message? I've never seen it outside of connection issues. – M. Eriksson Jan 03 '19 at 13:04
  • @MagnusEriksson In my case I was using mongo drivers $mngrMongo = new MongoDB\Driver\Manager(); $queryMongo = new MongoDB\Driver\Query([]); – Sayed Mohd Ali Jan 03 '19 at 13:05
  • @code511788465541441 I have updated my answer with more solutions. – Sayed Mohd Ali Jan 03 '19 at 13:43
  • OP has the tag `windows`. – nice_dev Jan 03 '19 at 13:53
  • MongoDB and PDO are two totally different monsters and aren't related in any way shape or form. I also don't get the statement _"There must be Query like this one"_ if your experience are with Mongo, since Mongo doesn't even use SQL queries. Like I said before, this answer is currently just wild guesses, which isn't very constructive. Let's wait until the OP actually updates the question with the information we've asked for. – M. Eriksson Jan 03 '19 at 14:18
  • I was working on Hybrid mongo and MySQL both and the driver problem error was similar so I thought that It might be related there is nothing wrong in sharing the knowledge of your experience. – Sayed Mohd Ali Jan 03 '19 at 14:20
  • There's nothing wrong with that, but this particular question should actually be closed since the OP doesn't share the information needed to answer it (even though we've asked for it). – M. Eriksson Jan 03 '19 at 14:23