catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

PDOexception error #761

Closed merkdev closed 6 years ago

merkdev commented 6 years ago

I got this message even I had already installed PDO.

Fatal error: Uncaught PDOException: could not find driver in /var/www/html/vendor/catfan/medoo/src/Medoo.php:241 Stack trace: #0 /var/www/html/index.php(29): Medoo\Medoo->__construct(Array) #1 {main} thrown in /var/www/html/vendor/catfan/medoo/src/Medoo.php on line 241

I tried with 3 different VM's so the result is same. Has someone any idea what is wrong?

`// If you installed via composer, just use this code to requrie autoloader on the top of your projects. require 'vendor/autoload.php';

// Using Medoo namespace use Medoo\Medoo;

// Initialize $database = new Medoo([ 'database_type' => 'postgresql', 'database_name' => 'xxx', 'server' => 'localhost', 'username' => 'macbook', 'password' => '' ]);`

catfan commented 6 years ago

The error message is clear could not find driver.

You did not install PDO_XXX database driver extension for PostgreSQL.

Check out https://medoo.in/api/new to section PHP PDO Driver Installation

merkdev commented 6 years ago

Thanks for reply

I think, I have installed Postgres PDO successfully. Because this script works well (even if I uncomment semicolons in .ini file);

$dsn = "pgsql:host=localhost;port=5432;dbname=xxx;user=macbook;password=";

try{ // create a PostgreSQL database connection $conn = new PDO($dsn);

// display a message if connected to the PostgreSQL successfully if($conn){ echo "Connected to the $db database successfully!"; } }catch (PDOException $e){ // report error message echo $e->getMessage(); }

I don't know whats is wrong. There is an another PDO library for PHP ?

Here you can find my php info ;

https://jmp.sh/r3ndKmr

catfan commented 6 years ago

The database_type should be pgsql not postgresql.

merkdev commented 6 years ago

Now it works, thanks a lot..