View Full Version : FC4 PHP and SQLite
bkat
17th June 2005, 03:51 AM
I just upgraded to FC4 and one thing I can't figure out is PHP SQLite.
When trying to open a SQLite database via PEAR DB, I get an error stating that the sqlite extebsion isn't loaded. The PHP manuals state that sqlite is supposed to be bundled with PHP5.
I installed php-pecl-sqlite but it installed sqlite.so in /usr/lib/php4/sqlite.so instead of /usr/lib/php/modules.
I've also tried using the native php sqlite interface and it reports things like sqlite_open is undefined.
Is there some package I'm missing to get sqlite support in php5 on FC4?
bkat
20th June 2005, 01:10 AM
I eventually figured out how to get this working
Fedora ships php5 compiled with "--without sqlite". I believe the php-pecl-sqlite module is not compiled for php5, there is a bug report filed and it looks like the fedora folks are only supporting php-pecl-pdo-sqlite. However i have a significant amount of code that uses PEAR DB.
Start with installing php-pecl-sqlite
$ yum install php-pecl-sqlite
So I downloaded the php sqlite extension
$ pear download sqlite
then unpacked and began to compile it
$ tar zxvf SQLite-1.0.3.tgz
$ cd SQLite-1.0.3
$ phpize
$ ./configure
$ make
edit sqlite.c, comment out the following line:
/* static unsigned char arg3_force_ref[] = {3, BYREF_NONE, BYREF_NONE, BYREF_FORCE }; */
And then change these lines
function_entry sqlite_functions[] = {
PHP_FE(sqlite_open, arg3_force_ref)
PHP_FE(sqlite_popen, arg3_force_ref)
to:
function_entry sqlite_functions[] = {
PHP_FE(sqlite_open, third_arg_force_ref)
PHP_FE(sqlite_popen, third_arg_force_ref)
$ make
$ make install
$ cp modules/sqlite.so /usr/lib/php/modules
$ /sbin/service/httpd restart
It will still be nice if there was an official package that enables the builtin support for sqlite that comes with php5
jcwinnie
29th July 2005, 07:02 PM
Thanks for posting. I spent an aggravating hour or so trying to find it.
jcwinnie
3rd August 2005, 01:06 PM
I eventually figured out how to get this working
Start with installing php-pecl-sqlite
$ yum install php-pecl-sqlite
So I downloaded the php sqlite extension
$ pear download sqlite
I had some time today, so I thought I would try to fix the case of the missing sqlite.so. I tried your recommendation. Yes, it worked, although I did encounter a few differences on my FC4 system, to wit:
yum "donna know nothing bout no" php-pecl-sqlite
pear already was hinky because it missed sqlite terribly, so it just scoffed at my entreaties to "pear download" or "pear install".
Instead, I did:
wget -q http://pecl.php.net/get/SQLite-1.0.3.tgz
Otherwise, everything else I did according to your instructions seemed to result in a positive outcome. The last step of copying sqlite.so to the proper directory did seem to be uncessary.
Bottom Line: From every indication, sqlite works again and the command "pear upgrade" is back to nothing rather than an error message, your modification seemed to fix the brokeness.
Thanks
GRenard
2nd September 2005, 03:36 PM
You should create a file in /etc/php.d/ named sqlite.ini
Inside write this :
; Enable sqlite extension module
extension=sqlite.so
and AFTER restart the server !
Thank you
uberpimp
5th September 2005, 02:46 PM
you may also want to check the versions - php 5.0.4 has sqlite 2.8.x extensions integrated, new version (3.x.x) is accesible via the PDO stuff from pear - comes with PHP 5.1 or whatever - baked my noodle on Windows for a few days trying to mirror my server setup
i think.. wow, that second bottle of vin de terrible is kicking in :P - versions are vague at best...
Conscript89
27th November 2005, 07:14 PM
Thanks a lot for this topic, helped me to solve one problem with PHP and SQLite, but I have another problem.
I don't know why, but I can't use OOP with SQLite, PHP writes me undefined class error, I use this:
<?php
$db = new SQLiteDatabase("./crm.db", 0666, &$error) or die("Error: ".$error);
unset($db);
?>
Fatal error: Class 'SQLiteDatabase' not found in /var/www/html/php5/sqlite/first.php on line 2
strange thing is, that this one is working:
<?php
$db = sqlite_open("./crm.db", 0666, &$error) or die("Error: ".$error);
unset($db);
?>
I would be happy to solve this problem, I'm OOP n00b, but this sample was written in this book: http://www.amazon.com/gp/product/013147149X/102-2355971-4502509?v=glance&n=283155&s=books&v=glance
*edit: It was written in Czech version of this book, but It doesn't make difference.
cdaniel
14th March 2006, 03:15 PM
Hello!!!!
i was trying your recommended but i have this problem:
When i make a select of the database from php page, everything is ok..
but when i´m going to make an insert or an update from php page, show an error, that can't open database, but in the select, yes it can!!!!!!!!
And when i trying to do this instructions from the shell, everything right!!
I don´t understand.
I have this situation in two CPU: FC3 + SQLite 2 + Apache 2 + PHP4
and FC4 + Php 5+ Sqlite2 + Apache 2.
And I need that works with the PHP.
I hope you can help me with this trouble.
My name is Daniel and i'm from Colombia, excuse if my english its no good.
I eventually figured out how to get this working
Fedora ships php5 compiled with "--without sqlite". I believe the php-pecl-sqlite module is not compiled for php5, there is a bug report filed and it looks like the fedora folks are only supporting php-pecl-pdo-sqlite. However i have a significant amount of code that uses PEAR DB.
Start with installing php-pecl-sqlite
$ yum install php-pecl-sqlite
So I downloaded the php sqlite extension
$ pear download sqlite
then unpacked and began to compile it
$ tar zxvf SQLite-1.0.3.tgz
$ cd SQLite-1.0.3
$ phpize
$ ./configure
$ make
edit sqlite.c, comment out the following line:
/* static unsigned char arg3_force_ref[] = {3, BYREF_NONE, BYREF_NONE, BYREF_FORCE }; */
And then change these lines
function_entry sqlite_functions[] = {
PHP_FE(sqlite_open, arg3_force_ref)
PHP_FE(sqlite_popen, arg3_force_ref)
to:
function_entry sqlite_functions[] = {
PHP_FE(sqlite_open, third_arg_force_ref)
PHP_FE(sqlite_popen, third_arg_force_ref)
$ make
$ make install
$ cp modules/sqlite.so /usr/lib/php/modules
$ /sbin/service/httpd restart
It will still be nice if there was an official package that enables the builtin support for sqlite that comes with php5
bkat
14th March 2006, 03:40 PM
Hello!!!!
i was trying your recommended but i have this problem:
When i make a select of the database from php page, everything is ok..
but when i´m going to make an insert or an update from php page, show an error, that can't open database, but in the select, yes it can!!!!!!!!
Most likely this is a simple file permission problem. You should make sure that the database file and the directory it is in are writeable by httpd (user apache and group apache in a default config).
I take care of this by adding myself to group apache and then
$ chgrp apache /path_to_sqlite_database_dir /path_to_sqlite_database_dir/$file.db
$ chmod 775 /path_to_sqlite_database_dir
$ chmod 664 /path_to_sqlite_database_dir/$file.db
bkat
14th March 2006, 03:48 PM
you may also want to check the versions - php 5.0.4 has sqlite 2.8.x extensions integrated, new version (3.x.x) is accesible via the PDO stuff from pear - comes with PHP 5.1 or whatever - baked my noodle on Windows for a few days trying to mirror my server setup
Fedora Core 4 compiles php with "--without-sqlite" so there is no sqlite 2.8.x extensions integrated.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.