Jump to content
The Uniform Server Community
Sign in to follow this  
jani gracnar

php_pdo_sqlite - could not find driver

Recommended Posts

Hi,

 

I have a problem reading from sqlite 3 database.

I use UniServer Nano beta 2. I have copied php_pdo_sqlite.dll file (from original PHP 5.3) to php extensions directory and add line extension=php_pdo_sqlite.dll in php.ini file.

 

When try reading next error message is displayed:

could not find driver.

 

Reading with php_pdo_mysql is OK. The PHP code is tested on mini uniform server with php_pdo_sqlite.dll added and php.ini file modification.

 

 

Thanx for help,

 

Jani

Share this post


Link to post
Share on other sites

Hi Jani,

I am not sure if I fully understand the problem.

To configure sqlite on Beta 2

1) Copy files php_pdo_sqlite.dll and php_sqlite3.dll from PHP 5.3.0 distribution package to folder UniServer\usr\local\php

2) You need to edit the ini files there are three. Current working one is php.ini this will be overwritten when you use Unitray to switch between production and development. Three files are:

 

UniServer\usr\local\php\php.ini

UniServer\usr\local\php\php.ini_delvelopment_nano

UniServer\usr\local\php\ php.ini_production_nano

 

In each file locate these two lines:

 

;extension=php_pdo_sqlite.dll

;extension=php_sqlite3.dll

 

Remove the semi-colon as shown below:

 

extension=php_pdo_sqlite.dll

extension=php_sqlite3.dll

 

Note: Do not add your own lines to the file, just uncomment the existing lines. The modules need to be run in the order listed.

 

Restart the servers, run phpinfo() from Apanel and check these three sections are displayed and enabled:

pdo_sqlite

SQLite

sqlite3

 

I ran a quick test:

Created a new folder UniServer\www\test1

Created following script test.php and saved to folder UniServer\www

<?php
try {
/*** connect to SQLite database ***/
$dbh = new PDO("sqlite:test1/database.sdb");
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>

Ran the script by typing http://localhost/test.php

All it does is to create an empty database database.sdb in folder test1

 

Hope the above is of some help.

 

All the best

Ric :)

Share this post


Link to post
Share on other sites

Oops! The above test code was not for SQLite3 hence try this for testing:

<?php
$db = new SQLite3('test1/mysqlitedb3.db');

$db->exec('CREATE TABLE table_fred (variable_uniserver STRING)');
$db->exec("INSERT INTO table_fred (variable_uniserver) VALUES ('Uniform Server Test')");

$result = $db->query('SELECT variable_uniserver FROM table_fred');
var_dump($result->fetchArray());
?>

Note 1: 'test1/mysqlitedb3.db is either a relative path or absolute path to your database. In this example folder test1 must already exists in folder www

 

Note 2: With development PHP ini switched in

First run gives:

Result: array(2) { [0]=> string(19) "Uniform Server Test" ["variable_uniserver"]=> string(19) "Uniform Server Test" }

 

Sencond or more runs give:

Warning: SQLite3::exec() [sqlite3.exec]: table table_fred already exists in C:\mpg_uniserver_test_well_62g\UniServer\www\db_test_3.php on line 4

array(2) { [0]=> string(19) "Uniform Server Test" ["variable_uniserver"]=> string(19) "Uniform Server Test" }

 

Note 3: With production PHP ini switched in masks the warnings

Hence you get only:

Result: array(2) { [0]=> string(19) "Uniform Server Test" ["variable_uniserver"]=> string(19) "Uniform Server Test" }

 

All the best

Ric :)

Share this post


Link to post
Share on other sites

Hi,

 

Thank you for your help. Now it works everythink OK. Before your reply I made some mistakes. I changed the order of dlls calling in the ini file and I did not have right version of PHP as source for php_sqlite3.dll and php_pdo_sqlite.dll (now php-5.3.0-Win32-VC6-x86).

 

 

Thanx,

 

Jani

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...