标签:删除 exception 信息 cat result bind body cached tar
1、sql 绑定变量:
$title = ’iat001’; //绑定变量 $result = DB::query("SELECT * FROM articles WHERE title = :title")->bind(’title’, $title)->execute();
//直接赋值 $result = DB::query("SELECT * FROM articles WHERE title = :title")->param(’title’, ’iat001’)->execute();
//绑定多个参数 $result = DB::query("SELECT * FROM articles WHERE title = :title AND body = :body")->parameters(array(’title’ => $title, ’body’ => ’body001’))->execute();
2、数据 cache
//cached() 三个参数:缓存时间、缓存文件、是否存空值 $result = DB::query("SELECT * FROM articles")->cached(3600, "articles", false)->execute();
// 删除 articles 缓存文件 Cache::delete("articles"); // 删除 db 目录下的所有缓存 Cache::delete_all("db");
3、事务
try { //事务开始 DB::start_transaction(); $result = DB::insert(’articles’)->set(array(’title’ => ’iat001’, ’body’ => ’body001’))->execute(); // 自定义返回信息 DB::escape(‘ERROR:‘ . $msg); // 事务结束 DB::commit_transaction(); } catch(Exception $e) { // 事务回滚 DB::rollback_transaction(); // 回滚提示信息 $e->getMessage(); }
标签:删除 exception 信息 cat result bind body cached tar
原文地址:https://www.cnblogs.com/rendd/p/9372696.html