PHP から、PEAR::DB を介して sqlite2 データベースを使用する。
CentOS release 6.4 (Final), CentOS release 5.9 (Final)
PHP Version 5.3.3
DB 1.7.14 stable
PEAR 1.9.4 stable
構築手順... ▼
CentOS release 6.4 (Final), CentOS release 5.9 (Final)
PHP Version 5.3.3
DB 1.7.14 stable
PEAR 1.9.4 stable
構築手順... ▼
●phpize コマンドがなければ php-devel をインストール。
コンパイルするので make や gcc などの開発ツールも必要
http://www.php.net/downloads.php
●PECL
http://pecl.php.net/package/SQLite
●ソースに手を加える手法
などは、いずれもコンパイルに失敗。
Ethna で SQLite の試みへ続く
[root@fitPC2i ~]# yum install php-devel : [root@fitPC2i ~]# exit●ソースの取得・解凍
[taro@fitPC2i ~]$ wget http://museum.php.net/php5/php-5.3.3.tar.gz : [taro@fitPC2i ~]$ tar zxf php-5.3.3.tar.gz :●メイク
[taro@fitPC2i ~]$ cd ~/php-5.3.3/ext/sqlite [taro@fitPC2i sqlite]$ phpize Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626 config.m4:50: warning: AC_CACHE_VAL(pdo_inc_path, ...): suspicious cache-id, must contain _cv_ to be cached ../../lib/autoconf/general.m4:1974: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:1994: AC_CACHE_CHECK is expanded from... aclocal.m4:2743: PHP_CHECK_PDO_INCLUDES is expanded from... config.m4:50: the top level config.m4:50: warning: AC_CACHE_VAL(pdo_inc_path, ...): suspicious cache-id, must contain _cv_ to be cached ../../lib/autoconf/general.m4:1974: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:1994: AC_CACHE_CHECK is expanded from... aclocal.m4:2743: PHP_CHECK_PDO_INCLUDES is expanded from... config.m4:50: the top level [taro@fitPC2i sqlite]$ ./configure : [taro@fitPC2i sqlite]$ make :●インストール
[taro@fitPC2i sqlite]$ su パスワード: [root@fitPC2i sqlite]# make install Installing shared extensions: /usr/lib/php/modules/ Installing header files: /usr/include/php/●php設定ファイル
[root@fitPC2i sqlite]# vi /etc/php.d/sqlite.ini
extension=sqlite.so●webサーバ再起動
[root@fitPC2i sqlite]# service httpd restart : [root@fitPC2i sqlite]# exitsqlite.iniを削除してwebサーバ再起動すれば元に戻る。 ●確認 info.php
<⁄php date_default_timezone_set('Asia/Tokyo'); ini_set('mbstring.internal_encoding', 'UTF-8'); phpinfo(); ⁄>●例 (同じディレクトリに index.php, database.sqlite2)
<html> <head> <title>例</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <⁄php require_once 'DB.php'; $dsn = 'sqlite:///./database.sqlite2'; $db = DB::connect( $dsn ); $rset = $db->query('SELECT * FROM table'); $row = $rset->fetchRow( DB_FETCHMODE_ASSOC ); var_dump( $row ); ⁄> </body> </html>●PHP 5.3.26 (Old stable) ←異なるバージョン
http://www.php.net/downloads.php
●PECL
http://pecl.php.net/package/SQLite
●ソースに手を加える手法
などは、いずれもコンパイルに失敗。
Ethna で SQLite の試みへ続く