Jump to content


Photo

php_pdo_sqlite - could not find driver


  • Please log in to reply
3 replies to this topic

#1 jani gracnar

jani gracnar

    Junior Member

  • Member
  • Pip
  • 18 posts
  • Main OS: Windows XP

Posted 19 August 2009 - 07:14 AM

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

#2 Ric

Ric

    Project Manager

  • Admin
  • PipPipPipPipPip
  • 1,535 posts
  • Gender:Male
  • Location:Cambridge,UK
  • Interests:Electronics
    Internet in general
    Open source projects
  • SourceForge IDmpgcan
  • Wiki ID: Ric
  • Main OS: Windows XP

Posted 20 August 2009 - 01:39 PM

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 :)

#3 Ric

Ric

    Project Manager

  • Admin
  • PipPipPipPipPip
  • 1,535 posts
  • Gender:Male
  • Location:Cambridge,UK
  • Interests:Electronics
    Internet in general
    Open source projects
  • SourceForge IDmpgcan
  • Wiki ID: Ric
  • Main OS: Windows XP

Posted 20 August 2009 - 04:31 PM

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 :)

#4 jani gracnar

jani gracnar

    Junior Member

  • Member
  • Pip
  • 18 posts
  • Main OS: Windows XP

Posted 21 August 2009 - 01:06 AM

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




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users