jani gracnar Posted August 19, 2009 Report Share Posted August 19, 2009 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 Quote Link to comment Share on other sites More sharing options...
Ric Posted August 20, 2009 Report Share Posted August 20, 2009 Hi Jani,I am not sure if I fully understand the problem.To configure sqlite on Beta 21) Copy files php_pdo_sqlite.dll and php_sqlite3.dll from PHP 5.3.0 distribution package to folder UniServer\usr\local\php2) 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.iniUniServer\usr\local\php\php.ini_delvelopment_nanoUniServer\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.dllextension=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_sqliteSQLitesqlite3 I ran a quick test:Created a new folder UniServer\www\test1Created 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.phpAll it does is to create an empty database database.sdb in folder test1 Hope the above is of some help. All the bestRic Quote Link to comment Share on other sites More sharing options...
Ric Posted August 20, 2009 Report Share Posted August 20, 2009 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 inFirst 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 4array(2) { [0]=> string(19) "Uniform Server Test" ["variable_uniserver"]=> string(19) "Uniform Server Test" } Note 3: With production PHP ini switched in masks the warningsHence you get only:Result: array(2) { [0]=> string(19) "Uniform Server Test" ["variable_uniserver"]=> string(19) "Uniform Server Test" } All the bestRic Quote Link to comment Share on other sites More sharing options...
jani gracnar Posted August 21, 2009 Author Report Share Posted August 21, 2009 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.