[Lighttpd] How can I access SQLite from PHP?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gilles Ganault

    #1

    [Lighttpd] How can I access SQLite from PHP?

    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,uni xODBC,/usr' '--with-pdo-mysql=shared,/usr'
    '--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr'
    =====

    Thank you.
  • larry@portcommodore.com

    #2
    Re: How can I access SQLite from PHP?

    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)

    Comment

    • Gilles Ganault

      #3
      Re: How can I access SQLite from PHP?

      On Sat, 8 Dec 2007 20:19:00 -0800 (PST), larry@portcommo dore.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::ge tAvailableDrive rs() 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.

      Comment

      • =?ISO-8859-15?Q?Iv=E1n_S=E1nchez_Ortega?=

        #4
        Re: How can I access SQLite from PHP?

        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án Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

        MSN:i_eat_s_p_a _m_for_breakfas t@hotmail.com
        Jabber:ivansanc hez@jabber.org ; ivansanchez@kde talk.net

        Comment

        • Gilles Ganault

          #5
          Re: How can I access SQLite from PHP?

          On Sun, 09 Dec 2007 20:55:52 +0100, Iván Sánchez 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. :-)

          Comment

          • allain

            #6
            Re: How can I access SQLite from PHP?

            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,uni xODBC,/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

            Comment

            • Gilles Ganault

              #7
              Re: How can I access SQLite from PHP?

              On Sun, 9 Dec 2007 13:07:44 -0800 (PST), allain
              <allain.lalonde @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.

              Comment

              • Gilles Ganault

                #8
                Re: How can I access SQLite from PHP?

                On Sun, 9 Dec 2007 13:07:44 -0800 (PST), allain
                <allain.lalonde @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");

                Comment

                • chenny

                  #9
                  Re: How can I access SQLite from PHP?

                  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,uni xODBC,/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,uni xODBC,/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,uni xODBC,/usr' '--with-pdo-mysql=shared,/usr'
                  '--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr'
                  =====
                  >
                  Thank you.
                  learning

                  Comment

                  • Toby A Inkster

                    #10
                    Re: How can I access SQLite from PHP?

                    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

                    Comment

                    Working...