FC4 PHP and SQLite
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 10 of 10
  1. #1
    bkat Guest

    FC4 PHP and SQLite

    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?

  2. #2
    bkat Guest
    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

  3. #3
    jcwinnie Guest
    Thanks for posting. I spent an aggravating hour or so trying to find it.

  4. #4
    jcwinnie Guest

    Post Feedback, Jimi

    Quote Originally Posted by bkat
    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:

    1. yum "donna know nothing bout no" php-pecl-sqlite
    2. 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:
    Code:
    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

  5. #5
    GRenard Guest
    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

  6. #6
    uberpimp Guest
    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...

  7. #7
    Join Date
    Sep 2005
    Location
    Olomouc, Czech Republic, Central Europe
    Age
    32
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    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:
    Code:
    <?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:
    Code:
    <?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/013...books&v=glance
    *edit: It was written in Czech version of this book, but It doesn't make difference.
    Last edited by Conscript89; 27th November 2005 at 07:51 PM.

  8. #8
    cdaniel Guest

    Sqlite trouble

    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 im 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 dont 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.






    Quote Originally Posted by bkat
    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

  9. #9
    bkat Guest
    Quote Originally Posted by cdaniel
    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 im 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

  10. #10
    bkat Guest
    Quote Originally Posted by uberpimp
    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.

Similar Threads

  1. SQLite Problems...
    By osprey in forum Servers & Networking
    Replies: 2
    Last Post: 16th June 2007, 10:48 PM
  2. FC5, PHP, and SQLite
    By bkat in forum EOL (End Of Life) Versions
    Replies: 6
    Last Post: 11th July 2006, 02:22 AM
  3. using sqlite in PHP
    By PurpleT in forum Using Fedora
    Replies: 0
    Last Post: 19th July 2005, 06:47 PM
  4. sqlite for php5
    By sn0n in forum Servers & Networking
    Replies: 0
    Last Post: 22nd March 2005, 10:55 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •