2

The php manpage sais, you have to install sqlite via PECL, so I tried the latest version:

cd /tmp/
wget https://pecl.php.net/get/SQLite-1.0.3.tgz
tar xvzf SQLite-1.0.3.tgz
cd SQLite-1.0.3/
phpize

But I cannot install php_sqlite on Ubuntu 15.10 like this. I get an error at make :

/tmp/SQLite-1.0.3/sqlite.c: In function 'zif_sqlite_open':
/usr/include/php5/main/php_globals.h:32:29: error: 'struct _php_core_globals' has no member named 'safe_mode'

And many more, so is there an actual version working on PHP 5.6?

I want to run an old program that uses the function sqlite_open

And installing the package didn't make it work:

apt-get install php5-sqlite

So maybe there's a good wrapper library around that uses SQLite3::open to simulate the old functions?

1
  • As of PHP 5.4 sqlite is no longer part of PHP and in only available through PECL. Commented Jun 9, 2016 at 22:41

2 Answers 2

4

I've been wracking my brain for a couple of days on this, but this finally worked for me:

sudo apt-get install php5.6-sqlite3

I have php5.6 as an executable so I then confirmed that php5.6 -m showed sqlite3 to be loaded and it was.

After that, I was able to execute the following simple script. Previously it was telling me that the class SQLite3 was not found.

<?php
   class MyDB extends SQLite3
   {
      function __construct()
      {
         $this->open('test.db');
      }
   }

   $db = new MyDB();
   if(!$db){
      echo $db->lastErrorMsg();
   } else {
      echo "Opened database successfully\n";
   }
Sign up to request clarification or add additional context in comments.

Comments

0

As far as I can see the pecl page shows that package was last updated in 2004. The link you linked also states: "(PHP 5 < 5.4.0, PECL sqlite >= 1.0.0)". Simply said It's not for 5.6.

Regardless you should just install the default package instead of using pecl when this is an option. For ubuntu this is php5-sqlite.

The extension you linked is very old. I would recommend taking a look at SQLite3 which should be included by default.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.