samedi 2 mai 2015

Why can't create the sqlite db with PDO?

I am in debian7.

<?php
echo "creating a databse \n";
try {
    $dbh=new PDO('sqlite:voting.db');
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $dbh->exec('
    CREATE TABLE tally(
    QID varchar(32) NOT NULL,
    AID integer NOT NULL,
    votes integer NOT NULL,
    PRIMARY KEY(QID,AID)
    )');


} catch (Exception $e) {
    echo "error!!:$e";
    exit;

}
echo "db created successfully!";
?>

I want to create my sqlite db voting.db with the code,it ran accross error info:

creating a databse error!!:exception 'PDOException' with message 'could not find driver' in /var/www/sqlite1.php:4 Stack trace: #0 /var/www/sqlite1.php(4): PDO->__construct('sqlite:voting.d...') #1 {main}

How to fix it?

Aucun commentaire:

Enregistrer un commentaire