By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 1,944 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

[Lighttpd] How can I access SQLite from PHP?

P: n/a
Hello

I was looking for a lighter web server than Apache, and
installed Lighttpd on CentOS through yum. It works fine, but I now
need to use SQLite from a PHP script. I seem to understand that it can
either be access directly, or through the PDO interface.

Can you confirm that the RPM that I used will only allow me to work
through PDO, and not the SQLite library directly, and which is more
recommended?

=====
PHP Version 5.1.6

System Linux asterisk.acme 2.6.18-8.1.15.el5 #1 SMP Mon Oct 22
08:32:04 EDT 2007 i686

Build Date Sep 20 2007 10:01:50

Configure Command './configure' [...] '--without-sqlite' [...]
'--enable-fastcgi' '--enable-pdo=shared'
'--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-mysql=shared,/usr'
'--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr'
=====

Thank you.
Dec 9 '07 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On Dec 8, 6:54 pm, Gilles Ganault <nos...@nospam.comwrote:
Hello

I was looking for a lighter web server than Apache, and
installed Lighttpd on CentOS through yum. It works fine, but I now
need to use SQLite from a PHP script. I seem to understand that it can
either be access directly, or through the PDO interface.

Can you confirm that the RPM that I used will only allow me to work
through PDO, and not the SQLite library directly, and which is more
recommended?
In Centos sqlite may not have been automatically installed or PHP was
not configured the SQL Lite libraries, do a quick check first to see
if sqlite is installed and then check the sqlite docs and make sure
php.ini has the proper settings to recognize it existing. (I've had to
do similar with setting up MySQL in Centos)
Dec 9 '07 #2

P: n/a
On Sat, 8 Dec 2007 20:19:00 -0800 (PST), la***@portcommodore.com
wrote:
>In Centos sqlite may not have been automatically installed or PHP was
not configured the SQL Lite libraries, do a quick check first to see
if sqlite is installed and then check the sqlite docs and make sure
php.ini has the proper settings to recognize it existing. (I've had to
do similar with setting up MySQL in Centos)
Thanks for the tip. Apparently, it's working. For those interested, I
did the following:

1. Remove Apache
2. Install the Lighttpd package
3. Install the Lighttpd FastCGI package
4. If not already installed, install PHP, including the FastCGI
version (run "php -v", and "php-cgi -v" to check)
5. Install the PDO package, which includes the SQLite module
6. Add this to a PHP page in Lighttp's www directory to check that the
whole thing works:
foreach(PDO::getAvailableDrivers() as $driver)
{
echo $driver.'<br />';
}

=Apparently, there are two ways to access SQLite from PHP: Either
directly, or through PDO. Is that correct? Which is better? Are there
other ways I should know about?

Thank you.
Dec 9 '07 #3

P: n/a
Gilles Ganault wrote:
=Apparently, there are two ways to access SQLite from PHP: Either
directly, or through PDO. Is that correct?
Yes. (assuming that by "directly" you mean "through the SQLite libraries")
Which is better?
Depends on your meaning of "better".

--
----------------------------------
Iv醤 S醤chez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

MSN:i_*************************@hotmail.com
Jabber:iv*********@jabber.org ; iv*********@kdetalk.net
Dec 9 '07 #4

P: n/a
On Sun, 09 Dec 2007 20:55:52 +0100, Iv醤 S醤chez Ortega
<ivansanchez-alg@rroba-escomposlinux.-.punto.-.orgwrote:
>Yes. (assuming that by "directly" you mean "through the SQLite libraries")
Yup, that's what I meant. Here's what CentOS has installed:

# rpm -qa | grep sqlite
sqlite-3.3.6-2
python-sqlite-1.1.7-1.2.1

# rpm -qa | grep php
php-cli-5.1.6-15.el5
php-common-5.1.6-15.el5
php-pdo-5.1.6-15.el5
>Depends on your meaning of "better".
Which is recommended for production work, has the more traction, is
the more stable, etc. :-)
Dec 9 '07 #5

P: n/a
On Dec 8, 9:54 pm, Gilles Ganault <nos...@nospam.comwrote:
Hello

I was looking for a lighter web server than Apache, and
installed Lighttpd on CentOS through yum. It works fine, but I now
need to use SQLite from a PHP script. I seem to understand that it can
either be access directly, or through the PDO interface.

Can you confirm that the RPM that I used will only allow me to work
through PDO, and not the SQLite library directly, and which is more
recommended?

=====
PHP Version 5.1.6

System Linux asterisk.acme 2.6.18-8.1.15.el5 #1 SMP Mon Oct 22
08:32:04 EDT 2007 i686

Build Date Sep 20 2007 10:01:50

Configure Command './configure' [...] '--without-sqlite' [...]
'--enable-fastcgi' '--enable-pdo=shared'
'--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-mysql=shared,/usr'
'--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr'
=====

Thank you.
PDO vs. sqlite functions?

Probably PDO. Overhead of using it is minimal, and it's a consistent
interface in case you decide to use some other backend later.

I'm not saying that you'll be able to just swap out another database
without problems, but when/if you do then you won't have to learn a
set of new functions.

Just my 2 cents,
Allain
Dec 9 '07 #6

P: n/a
On Sun, 9 Dec 2007 13:07:44 -0800 (PST), allain
<al************@gmail.comwrote:
>Probably PDO. Overhead of using it is minimal, and it's a consistent
interface in case you decide to use some other backend later.
Thanks. I probably won't need to switch to another database. I was
just wondering how to work with SQLite from PHP scripts.

Thanks.
Dec 9 '07 #7

P: n/a
On Sun, 9 Dec 2007 13:07:44 -0800 (PST), allain
<al************@gmail.comwrote:
>PDO vs. sqlite functions?
BTW, are the two following versions used when SQLite was compiled into
PHP (which it isn't in the RPM package that I used to install PHP)?

$db = new SQLiteDatabase("db.sqlite");
$db = sqlite_open("db.sqlite");
http://devzone.zend.com/node/view/id/760
Dec 10 '07 #8

P: n/a
On 12月9日, 上午10时54分, Gilles Ganault <nos...@nospam.comwrote:
Hello

I was looking for a lighter web server than Apache, and
installed Lighttpd on CentOS through yum. It works fine, but I now
need to use SQLite from a PHP script. I seem to understand that it can
either be access directly, or through the PDO interface.

Can you confirm that the RPM that I used will only allow me to work
through PDO, and not the SQLite library directly, and which is more
recommended?

=====
PHP Version 5.1.6

System Linux asterisk.acme 2.6.18-8.1.15.el5 #1 SMP Mon Oct 22
08:32:04 EDT 2007 i686

Build Date Sep 20 2007 10:01:50

Configure Command './configure' [...] '--without-sqlite' [...]
'--enable-fastcgi' '--enable-pdo=shared'
'--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-mysql=shared,/usr'
'--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr'
=====

Thank you.
On 12月9日, 上午10时54分, Gilles Ganault <nos...@nospam.comwrote:
Hello

I was looking for a lighter web server than Apache, and
installed Lighttpd on CentOS through yum. It works fine, but I now
need to use SQLite from a PHP script. I seem to understand that it can
either be access directly, or through the PDO interface.

Can you confirm that the RPM that I used will only allow me to work
through PDO, and not the SQLite library directly, and which is more
recommended?

=====
PHP Version 5.1.6

System Linux asterisk.acme 2.6.18-8.1.15.el5 #1 SMP Mon Oct 22
08:32:04 EDT 2007 i686

Build Date Sep 20 2007 10:01:50

Configure Command './configure' [...] '--without-sqlite' [...]
'--enable-fastcgi' '--enable-pdo=shared'
'--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-mysql=shared,/usr'
'--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr'
=====

Thank you.
On 12月9日, 上午10时54分, Gilles Ganault <nos...@nospam.comwrote:
Hello

I was looking for a lighter web server than Apache, and
installed Lighttpd on CentOS through yum. It works fine, but I now
need to use SQLite from a PHP script. I seem to understand that it can
either be access directly, or through the PDO interface.

Can you confirm that the RPM that I used will only allow me to work
through PDO, and not the SQLite library directly, and which is more
recommended?

=====
PHP Version 5.1.6

System Linux asterisk.acme 2.6.18-8.1.15.el5 #1 SMP Mon Oct 22
08:32:04 EDT 2007 i686

Build Date Sep 20 2007 10:01:50

Configure Command './configure' [...] '--without-sqlite' [...]
'--enable-fastcgi' '--enable-pdo=shared'
'--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-mysql=shared,/usr'
'--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr'
=====

Thank you.
learning
Dec 10 '07 #9

P: n/a
Gilles Ganault wrote:
allain wrote:
>Probably PDO. Overhead of using it is minimal, and it's a consistent
interface in case you decide to use some other backend later.

Thanks. I probably won't need to switch to another database.
I'd recommend PDO all the same -- the non-PDO database drivers are already
starting to look quite unmaintained. e.g. the non-PDO driver for SQLite
doesn't support SQLite3, whereas PDO does.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 4 days, 2:57.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/1...tunes-sharing/
Dec 11 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.