## 整理ThinkPHP常见数据库操作API
分类 | 操作 |
1 | import("lib.Page"); |
引用第三方库 | |
2 | public function _initialize(){ |
设置文档的编码方式,支持中文显示和插入中文 | |
3 | $img_path = __DIR__.'\..\..\..\Public\Uploads\task_1'; |
表示当前路径 -> 打开指定的文件夹 -> 读取文件夹中文件名 -> 关闭句柄 | |
4 | $download_file = array(); |
数组定义 -> 数组初始化 -> 数组的长度 | |
5 | $users = $user_tb->where(array("name" => $_GET["name"]))->select(); |
条件filter数据记录 -> 记录递增/递减 -> 限定条目输出 -> 输出记录字段 | |
6 | $arr["ret"] = false; |
构建hash数组 | |
7 | cookie("username",$_GET["name"]); |
加元素到Cookie中 -> 清除Cookie中元素 -> 获取Cookie中元素 | |
8 | $this->ajaxReturn ($arr,"JSON"); |
采用json的格式返回ajax请求 | |
9 | $this->redirect("Login"); |
页面重定向 | |
10 | $table = M('bug_table'); |
添加数据库记录 | |
11 | $this->assign('list',$list); |
12 | date('Y-m-d H:i:s',time()); |
获取日期 | |
13 | file_exists(__DIR__.'\persons.xml') |
文件存在性判断 -> 读取xml文件到记录对象 | |
14 | foreach($love as $lv){ $lv } |
遍历数组 | |
15 | __PUBLIC__ ,__URL__ , __SELF__ ,__DIR__ , , |
| |
16 | iconv("UTF-8", "GB2312",$v); |
将变量$v从UTF-8转为GB2312格式 | |
17 | $dat['name'] = $_GET["name"]; |
更新数据库记录 | |
18 | $table->where("id > %d",$id)->delete(); |
删除数据库记录 | |
| 页面尾部输出用于调试 |