0

i just realized that the rpm version of php that i have installed on the server don't have sqlite support (well it have the PDO support but for some reason don't work)

so i installed as a PECL extension, and now it show the support on the phpinfo() but still the open inviter script give me the error of:

Call to undefined function sqlite_open()

and i already restarted httpd also

any hint where i can find a solution or guide?

shadow_of__soul
  • 376
  • 1
  • 6
  • 16

2 Answers2

1

Remove php* packages and install equivalent php53* packages - they're available since RHEL/CentOS 5.6. They support sqlite PDO out of the box.

You can test this. Create a file /tmp/test-pdo-sqlite.php with contents:

<?php
try {
        $dbh=new PDO('sqlite:test.sqlite');
        $version = $dbh->query('select sqlite_version()')->fetchColumn();
        echo $version, "\n";
} catch (PDOException $e) {
        trigger_error("Error!: " . $e->getMessage(),E_USER_ERROR);
}
?>

And run it with cd /tmp/; php test-pdo-sqlite.php - on my CentOS 5 with php53 I get:

3.3.6

I have the following packages installed:

$ rpm -qa --qf='%{NAME}\n' | grep php | sort
php53
php53-cli
php53-common
php53-gd
php53-mbstring
php53-mcrypt
php53-mysql
php53-pdo
Tometzky
  • 2,679
  • 4
  • 26
  • 32
0

All over the Internet you can find questions and answers regarding sqlite support in PHP on Fedora Core, Red Hat, and CentOS distributions. While many of them have differences in how to go about enabling support, all of them say the same thing about the cause: packages for PHP on those distributions are compiled without support for SQLite (to my knowledge it was not built into these distributions since Fedora Core 4). To my knowledge there are no current RPM's for easily installing php-sqlite3.

Additionally, it is not recommended that you install the PECL extension for SQLite, as that is deprecated and no longer supported.

That being said, PHP on these distributions does include support for php-pdo and you can use that to access sqlite databases. The primary differences are the connection strings (you do not use sqlite_open but instead use a pdo string - for example: $db = new PDO('sqlite:/tmp/foo.db');). A list of sqlite functions using PDO can be found in the PHP Manual. I believe that if you modify your code to use these functions instead of the functions in php-sqlite that your problems will be solved.

If you need php-sqlite support and php-pdo does not work, you can try the following to recompile php with support for php-sqlite. Download the source for PHP from http://php.net/downloads.php and compile it with support for the SQLite module.

tar xfvj php-5.3.2.tar.bz2 
cd php-5.3.2/ext/sqlite/
phpize
./configure
make
make install
/etc/init.d/httpd restart
runlevelsix
  • 2,619
  • 22
  • 20
  • sorry but this didn't work, even the phpinfo() show the support of sqlite3, i'm getting the same error. the change of the code to support PDO is not a option in this case. – shadow_of__soul Jul 25 '10 at 19:52