I am trying to get PDO for sqlite to work on my localhost system. I
have modified the PHP5.ini file as shown below and run the following
PHP script. As stated below, it reports the mssql, mysql and sqlite2
drivers but then gives a "could not find driver" exception. Any help
is greatly appreciated. Also, I am concerned if PDO for sqlite is
widely supported by hosting companies, any input or opinions on that?
<?php
foreach(PDO::getAvailableDrivers() as $driver)
{
echo $driver.'<br />';
}
try {
/*** connect to SQLite database ***/
$dbh = new PDO("sqlite:./johns.db");
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>
Reports available drivers as mssql, mysql and sqlite2 (strange it is
sqlite2 when PDO is sqlite3 from what I understand)
Then throws the exception "could not find driver"
PHP.ini settings are:
extension=php_pdo.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_oci8.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_perl.dll
extension=php_pgsql.dll
;extension=php_phpdoc.dll
;extension=php_pop3.dll
;extension=php_printer.dll
;extension=php_pspell.dll
;extension=php_radius.dll
;extension=php_runkit.dll
;extension=php_sdo.dll
;extension=php_sdo_das_xml.dll
;extension=php_shmop.dll
;extension=php_smtp.dll
;extension=php_snmp.dll
extension=php_soap.dll
extension=php_sockets.dll
extension=php_sqlite.dll
and php_pdo_sqlite.dll is found in the /php/ext/ directory.
TIA,
John
Either your php_pdo_sqlite.dll extension or PHP Version hast a bug or
you have changed the wrong php.ini file.
Sometimes there are multiple php.ini files one in /php/ and one in
system dir.
Regards
purcaholic
I only find php.ini and php5.ini and I changed both of them. I also
downloaded php_pdo_sqlite.dll and replaced the one in my /ext/
directory.
What I have found is that if I change my code from
/*** connect to SQLite database ***/
$dbh = new PDO("sqlite2:./johns.db");
It does connect via PDO but again using sqlite2. So I am at a loss.
Seems like something wrong in my PHP or DLL. But I do not know about
rebuilding such things.
Any other suggestions?
TIA,
John
Try
$dbh = new PDO("sqlite3:./johns.db");
I believe sqlite: defaults to version 2. The other thing I'll mention
is that php5.ini are the suggested settings for PHP version 5. Sounds
like you might have a version of XAMPP installed which I think installs
two versions of PHP as well as Apache, Perl, MySQL, SQLite, et al.
Apache Version 2 (not sure if a specific subversion is required) supports
a PHPIniDir directive, see
http://www.php.net/manual/en/install.windows.apache2.php
for documentation. They show PHPIniDir getting configured inside the
httpd.conf file as follows, you will need to change the folder to
point to the appropriate folder in which your php.ini file resides:
PHPIniDir "C:/php"
NOTE, it does NOT provide a way to change the name of PHP.INI, so
I can not help in regards as how to configure Apache to use BOTH the
PHP4 and PHP5. My understanding has always been that ONE and ONLY ONE
version of PHP gets installed, but then again I've never tried to run
two different versions at the same time. I just do not see a way to
configure the:
AddType application/x-httpd-php .php
without recompiling and changing that Type string.
The php_pdo_sqlite.dll is the file representing version 3 methods for
accessing, creating and updating SQLite version 3 data files. And then
php_sqlite.dll represents the file for accessing SQLite Version 2 of
the data files. I started a webpage last year, but never finished it,
detailing how to create and access the different files.
http://www.microcosmotalk.com/tech/windows/php/sqlite/
The details are accurate but incomplete. If it's helpful, let me know,
if something needs to get updated or is confusing, please let me know
and I will update it.
I'll watch this thread for any and all replies as I need to complete
the information there.
Can you offer some more information about your Apache/PHP install?
--
Jim Carlock
You Have More Than Five Senses
http://www.associatedcontent.com/article/381163/more_than_five_senses.html
Hi Jim,
Thank you for your help. I will need to research all you presented,
but here is a quick response to your question about versions.
According to the XAMP readme file:
###### ApacheFriends XAMPP (basic package) version 1.6.6a ######
Apache 2.2.8
MySQL 5.0.51a
PHP 5.2.5 + PHP 4.4.8 + PEAR
PHP-Switch win32 1.0 (please use the "php-switch.bat")
XAMPP Control Version 2.5 from www.nat32.com
XAMPP Security 1.0
SQLite 2.8.15
OpenSSL 0.9.8g
phpMyAdmin 2.11.4
ADOdb 4.96
Mercury Mail Transport System v4.52
FileZilla FTP Server 0.9.25
Webalizer 2.01-10
Zend Optimizer 3.3.0a
eAccelerator 0.9.5.2 for PHP 5.2.5 (comment out in the php.ini)
Also, I tried running the script with
$dbh = new PDO("sqlite3:./johns.db");
But that again fails.
Thanks for all the help,
John
I found the answer!!! From the XAMP website FAQ
http://www.apachefriends.org/en/xampp-windows.html
* Question 6: Where can I change the configuration?
You adjust XAMPP settings with plain-text configuration files. The
following files exist:
* Apache basic configuration: .\xampp\apache\conf\httpd.conf
* Apache SSL: .\xampp\apache\conf\ssl.conf
* Apache Perl (only addon): .\xampp\apache\conf\perl.conf
* Apache Tomcat (only addon): .\xampp\apache\conf\java.conf
* Apache Python (only addon): .\xampp\apache\conf\python.conf
* PHP: .\xampp\apache\bin\php.ini
(with the apache actually running php version)
* MySQL: .\xampp\mysql\bin\my.cnf
* phpMyAdmin: .\xampp\phpMyAdmin\config.inc.php
* FileZilla FTP: .\xampp\FileZillaFTP\FileZilla Server.xml
* Mercury Mail basic configuration: .\xampp\MercuryMail
\MERCURY.INI
* Sendmail: .\xampp\sendmail\sendmail.ini
I suddenly realized I was changing the php.ini file in the EXT
directory not the ./xampp/apache/bin/ directory!! Changed it by
uncommenting the php_pdo_sqlite extension and it worked great. So as
purcaholic said, I was changing the wrong php.ini file! I should have
went to the XAMPP site to begin with...live and learn. Thanks for
everyone's help.
John