codecamp

开始

链接

实例代码:

//如何使用? 命名空间引入 use \service\db;


//方法1 connect 提供一个参数 - 即读取配置实例 默认读取 default
$db = db::connect();


//方法2 读取其他数据库
$db = db::connect('other');


//$db 即是 sql 链接后的 link 对象


//如何销毁断开链接?
db::disconnect();


//or


db::disconnect('other');

特殊

上面文档说到驱动约定主键为 “id”,如果表的主键不是 id, 如何处理 ?

//提供一个方法叫 setPrimary // $table_name 特殊处理的表名 // $primary_key 当前表的主键字段名 $db->setPrimary($table_name,$primary_key);

快进行阅读下一个文档了解更多吧!

优势
API
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

应用

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }