2005-10-17

在 UBUNTU 5.04 版中如何使用 SQLite

SQLite 是一個不錯的資料庫軟體,它並不是使用 Server 及 client 的方式來運行.

在 PHP5 中己內定使用這個資料庫了,但由於 UBUNTU 5.04 使用的 PHP 版本是 4.X 所以要經過一些設定才可使用 SQLite.

在網路上查了許多相關資料,但實作上一直都失敗,到底那不是針對 UBUNTU 設定的.

後來在 Synaptic 中發現 php4-sqlite 這個軟體,看了一下說明,這正是我所想要的,就安裝了起來.但奇怪的是使用 phpinfo() 這個函數來檢查 PHP 的 extension 中還是沒有 SQLite 的資料,而且 sqlite.so 也存在著, 其路徑為/usr/lib/php4/20020429/sqlite.so


於是又使用 google 找了許多資料,但問題仍然沒有解決.

正想放棄時,靈光乍現,想到去看了一下 /usr/share/doc/php4-sqlite/README.Debian 這個檔案,有著以下的說明.


php4-sqlite for Debian
----------------------

The SQLite module doesn't get automatically added to the PHP4 config file,
as the package is new and I'm not keen on inflicting this (fairly beta) code
on unsuspecting people.

For now, add the following line to /etc/php4/{apache,cgi}/php.ini:

extension=sqlite.so

or, alternately, load the module at script runtime by calling:

dl('sqlite.so');

before trying to use the module in your code. Be warned, some versions of
the PEAR DB library don't have particularly good SQLite support - try
installing the latest version from PEAR by running 'pear upgrade DB'.

-- Matthew Palmer , Sat, 24 Jan 2004 16:08:44 +1100


所以解決的方法在 php.ini 中加入 extension=sqlite.so, SQLite 在 PHP 中就可正常運作了.

沒有留言 :

張貼留言