destoon 實用手冊2 資料庫操作

2021-06-05 06:26:30 字數 898 閱讀 2487

初始化系統後系統會自動連線資料庫,並將資料庫操作物件儲存在$db。資料庫操作方法請參考include/db_mysql.class.php函式原型,以下僅對常用操作舉例。

1、執行sql語句

$db->query("insert into `table` (`***`) values ('yyy')");

$db->query("update `table` set `***`='yyy' where `zzz`=1");

$db->query("delete from `table` where `zzz`=1");

2、讀取多條資訊

$a = array();

$result = $db->query("select * from `table` where `***`='yyy' order by `zzz` desc limit 0,10");

while($r = $db->fetch_array($result))

print_r($a);

3、讀取單條資訊

$a = $db->get_one("select * from `table` where `***`='yyy'");

print_r($a);

4、計算總數

$a = $db->get_one("select count(*) as num from `table` where `***`='yyy'");

echo $a['num'];

系統的表字首可以使用變數$dt_pre(一般在語句中使用)或者$db->pre(一般在函式中使用)。

如果在函式中使用資料庫操作,需要先進行global $db;

destoon 實用手冊3 系統常量與變數

常量 說明備註 dt root 站點物理路徑 dt path 站點首頁 dt skin 風格目錄 dt admin 是否在管理後台 dt domain cookie作用域 dt lang 站點語言 dt key 安全金鑰 dt charset 字元編碼 dt cache 快取目錄物理路徑 dt ve...

Rcpp實用手冊

c 對應於r的資料型別有如下這些 double numeric int integer string character logical bool 在c 中可以直接使用r的物件有 所有算術邏輯運算子都是可以向量化的 pow,include using namespace rcpp rcpp expo...

tar 實用手冊

url tar 命令用來將很多檔案打包成乙個單一的磁帶或者磁碟歸檔,並可從歸檔檔案恢復出檔案列表。當你需要通過 email 傳送大量檔案時或者傳輸檔案時非常有用。這裡我們介紹一些基本的使用場景。tar 的語法 tar options file.tar file1 file2 file.tar 是 t...