一個關於 GLOBALS 使用的怪現象

在整理一套運作在 php 4.x 的舊程式準備移植到新的 PHP 5.x 時, 順便動手改寫所有的 cookie function 成為一個獨立的 class, 卻無意中發現一個關於 GLOBALS 使用上的怪現象. Read the rest of this entry »

Posted in PHP. No Comments »

PDOStatement->execute 簡記

語法

bool PDOStatement::execute ([ array $input_parameters= array() ] )

說明

PDOStatement->execute 負責執行 PDO::prepare 的 SQL 描述, 返回布林值。

Read the rest of this entry »

Posted in PHP. No Comments »

關於圖形驗證碼產生器

圖形驗證碼的使用已行之有年。但,也破之有年。好久以前自己剛完成一個圖形驗證碼程式時,曾簡略地研究的一下 “留言機器人” 這個課題,那時就發現有網站發表如何攻破那時廣泛使用中的圖形驗證碼產生器。個人實在是沒有生命投入這種無意義的留言機器人攻防戰中。

Read the rest of this entry »

Posted in PHP. No Comments »

PDOStatement->bindParam 簡記

語法

bool PDOStatement::bindParam ( mixed $parameter , mixed &$variable [, int $data_type [, int $length [, mixed $driver_options ]]] )

說明

綁定 PHP 變數到對應的 “名稱描述” 或 “問號描述”, 可加上簡易的資料格式與長度驗證. 以 Boolen 為返回值.

Read the rest of this entry »

Posted in PHP. No Comments »

PDO::prepare 簡記

PDO::prepare

這是方法提供 SQL 描述作前沿驗證,屬於較為嚴謹的使用方法。由於 PDO::prepare 僅作 SQL 描述的驗證,真正的執行需搭配 PDOStatement::execute() 方法使用。

PDOStatement PDO::prepare ( string $statement [, array $driver_options= array() ] )

Read the rest of this entry »

Posted in PHP. No Comments »

PDO::query 簡記

PDO::query

可通泛應用的方法。負責執行交付的 SQL 陳述,並將回傳的執行結果作為 PDOStatement 物件。此方法相當適合一般性的 SELECT 語意使用。

Read the rest of this entry »

Posted in PHP. No Comments »

PDO::exec 簡記

PDO::exec

在 PDO 當中最為直接簡要的方式莫過於 PDO::exec。

int PDO::exec ( string $statement )

Read the rest of this entry »

Posted in PHP. No Comments »

strip_tags 函數 簡記

strip_tags() 除去 string 中的 html tags 是個簡便的方案。語法如下:

string strip_tags ( string $str [, string $allowable_tags ] )

不過假使 string source 的 html tags 不完整或有語法錯誤,將會濾除的正確性。由於有此缺陷在應用上必須謹慎。

Read the rest of this entry »

Posted in PHP. No Comments »

簡記 myisam_ftdump 指令

MySQL 內建了 fulltext 功能, 能指定資料表的特定欄位建立特殊 fulltext 索引。源於此故,MySQL 也支援了一個衍生的 client 指令 “myisam_ftdump“。

此指令可以讓使用者查看 資料表 中的 fulltext 欄位,實際建立索引的詳細情況。使用語法如下:

Read the rest of this entry »

Posted in MySQL. No Comments »

上線實測 autoComplete + fulltext 搜尋

scws 分詞詞典與關鍵辭字典的整理暫時告一段落, 改寫相關的 js 程式後決定先上線測試。YUI autoComplete 的部份僅做了小變動,當輸入資料完全沒有選擇 autoComplete 項目的 fulltext 搜尋功能。暫時不對 fulltext 的搜尋結果作分頁,也暫時省略了匹配內容區段資料的輸出,後者先放在測試程式中繼續作測試。

測試一週看看 fulltext 匹配情況,用來續作微調依據。

ps: input maxlength 先限定為 80. browser autocomplete 也設定為 off。