J
J
Jonh Doe2014-02-11 10:33:32
PHP
Jonh Doe, 2014-02-11 10:33:32

PHP PDO SQLITE: how to fix "could not find driver" error?

There is a server running apache+php on it.
phpinfo says that:

PDO
PDO support	enabled
PDO drivers	sqlite2

But when I try to connect the database, I get the "could not find driver" exception. I
connect it like this:
try {
  $this->link = new PDO('sqlite:./db/mydb.sqlite2');
  $this->link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
  exit($e -> getMessage());
}

What to do? How to fix?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Osher, 2014-02-11
@CodeByZen

Actually, by default sqlite3.

try {
    $this->link = new PDO('sqlite2:./db/mydb.sqlite2');
    $this->link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
    exit($e -> getMessage());
}

Y
Yuri Efin, 2016-07-02
@Gambits

apt-get install php5-mysql

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question