關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • PHP 下使用 Text Database

    Posted on September 14th, 2006 Sam Tang No comments

    PHP + MySQL 是很熱門的配搭,因為有了 MySQL 作為資料庫系統,在搜索資料時就方便很多。但如果主機不是自己架設,而是租用 web hosting 的話,有些情況是沒有 MySQL 支援,這時就要用文字檔儲存資料。幸好有人寫出 text base 的資料庫程式,可以使用文字檔儲存資料,及用類似資料庫的操作,開發程式就方便得多了,以下是兩款 Text Database 的選擇:

    SQLite:
    要在 PHP 使用 SQLite,必須要讓主機支援 SQLite,以下是三種方法:
    1. Linux / Unix 系統: 在編譯 PHP 時加上 "–with-sqlite" 選項,及重新啟動 web server。

    2. Windows: 如果是主機是 Windows 的話,先下載 DLL 版本的 SQLite extension: php_sqlite.dll,然後便需要開啟 php.ini,並加入以下兩行:

    extension=php_pdo.dll
    extension=php_sqlite.dll

    3. PEAR: 如果不想更改 PHP 的設定,還可以用 PEAR installer 安裝 :

    pear install sqlite

    PHP Text DB API
    PHP Text DB API 是一套 PHP class,即是只需上載到 web server 及引入程式內即可。可以用 SQL 語句存取文字檔,還內建一套小型 GUI 管理程式。


    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word