$db->hide_errors
-----------------------------------------------------------------------------------------------------------------------
$db->hide_errors – turn ezSQL error output to browser off
關閉ezsql的錯誤輸出
Description
說明
$db->hide_errors( void )
$db->hide_errors() stops error output from being printed to the web clIEnt. If you would like to stop error output but still be able to trap errors for debugging or for your own error output function you can make use of the global error array $EZSQL_ERROR.
$db->hide_errors()停止向客戶端輸出ezsql的錯誤提示,如果你希望在關閉錯誤提示後依然能夠得到調試的錯誤信息或你自己的錯誤提示函數,你可以使用全局數組$EZSQL_ERROR得到錯誤提示。
Note: If there were no errors then the global error array $EZSQL_ERROR will evaluate to false. If there were one or more errors then it will have the following structure. Errors are added to the array in order of being called.
注意:如果沒有任何錯誤的話,全局數組$EZSQL_ERROR將置為false,如果有任何錯誤的話,將被以如下方式存入數組以備調用。
(以下為ez內部函數區,翻譯了也用不了,所以不翻譯了,反正大家都知道+_+)
$EZSQL_ERROR[0] = Array
[query] => SOME BAD QUERY
[error_str] => You have an error in your SQL syntax near ‘SOME BAD QUERY' at line 1
$EZSQL_ERROR[1] = Array
[query] => ANOTHER BAD QUERY
[error_str] => You have an error in your SQL syntax near ‘ANOTHER BAD QUERY' at line 1
$EZSQL_ERROR[2] = Array
[query] => THIRD BAD QUERY
[error_str] => You have an error in your SQL syntax near ‘THIRD BAD QUERY' at line 1
Example 1
例子
// Using a custom error function
使用一個常規的錯誤函數
$db->hide_errors();
// Make a silly query that will produce an error
使用一個錯誤的查詢來制造一個錯誤信息。
$db->query(“INSERT INTO my_table A BAD QUERY THAT GENERATES AN ERROR”);
// And another one, for good measure
$db->query(“ANOTHER BAD QUERY THAT GENERATES AN ERROR”);
用另一個來做對照
// If the global error array exists at all then we know there was 1 or more ezSQL errors..
如果全局錯誤數組存在,我們將得到這裡存在一個或多個ezsql的錯誤。
if ( $EZSQL_ERROR )
// VIEw the errors
$db->vardump($EZSQL_ERROR);
else
echo “No Errors”;
$db->show_errors
------------------------------------------------------------------------------------------------------------------
$db->show_errors – turn ezSQL error output to browser on
打開ezsql的錯誤輸出
Description
說明
$db->show_errors( void )
$db->show_errors() turns ezSQL error output to the browser on. If you have not used the function $db->hide_errors this function (show_errors) will have no effect.
打開ezsql的錯誤輸出,在未使用函數$db->hide_errors之前,此函數無效。
$db->escape
$db->escape – Format a string correctly in order to stop accidental mal formed querIEs under all PHP conditions.
格式化任何非標准PHP查詢
Description
說明
$db->escape( string )
$db->escape() makes any string safe to use as a value in a query under all PHP conditions.
格式化任何非標准PHP查詢使之適用於PHP環境
I.E. if magic quotes are turned on or off.
附加:無視magic quotes(自動轉義)
Note: Should not be used by itself to guard against SQL injection attacks. The purpose of this function is to stop accidental mal formed querIEs.
注意:不可用於防范sql注入攻擊,該函數僅用於格式化非標准查詢。
Example 1
例子1
// Escape and assign the value..
格式化值
$title = $db->escape(“Justin’s and Amy’s Home Page”);
// Insert in to the DB..
插入數據庫
$db->query(“INSERT INTO pages (title) VALUES (’$title’)”) ;
Example 2
例子2
// Assign the value..
分配值
$title = “Justin’s and Amy’s Home Page”;
// Insert in to the DB and escape at the same time..
在插入數據庫的時候格式化它
$db->query(“INSERT INTO pages (title) VALUES (’”. $db->escape($title).”’)”) ;
Disk Caching
-------------------------------------------------------------------------------------------------------------
ezSQL has the ability to cache your querIEs which can make dynamic sites run much faster.
Ezsql可以緩存你的查詢使動態網站能運行的更快
If you want to cache EVERYTHING just do..如果你希望緩存所有結果,可以這麼做
$db->use_disk_cache = true;
$db->cache_querIEs = true;
$db->cache_timeout = 24;
For full details and more specific options please see:
你可以查看以下文件來得到該參數的進一步信息
・MySQL/disk_cache_example.PHP
・Oracle8_9/disk_cache_example.PHP
至此為止,本次對於ezsql readme文件的漢化到此結束,本次漢化為期一周,大部分信息均以自身的經驗為參照,對於部分不太清楚的內容參考了百度的一些注釋。不排除有錯。