DB类应用示例
- /**
- * DB操作示例
- *
- * findAll
- *
- * @return void
- */
- public function dbFindAllDemo()
- {
- $where = [
- 'id' => ['>=', 2],
- ];
- $instance = DB::table('user');
- $res = $instance->where($where)
- ->orderBy('id asc')
- ->limit(5)
- ->findAll(['id','create_at']);
- $sql = $instance->sql;
- return $res;
- }
Model类应用示例
- // controller 代码
- /**
- * model example
- *
- * @return mixed
- */
- public function modelExample()
- {
- try {
- DB::beginTransaction();
- $testTableModel = new TestTable();
- // find one data
- $testTableModel->modelFindOneDemo();
- // find all data
- $testTableModel->modelFindAllDemo();
- // save data
推荐阅读
科技公司裁撤中年技巧员工的传闻,每隔一段时光就会在网上漫溢、发酵。法度榜样员们有点懵。十年前,当他们踏着高考重点登科线,走进大年夜学计算机院系的时刻,想象的而立生活必定不是如>>>详细阅读
本文标题:从0开始构建一个属于你自己的PHP框架
地址:http://www.17bianji.com/lsqh/35069.html
1/2 1

网友点评
精彩导读
科技快报
品牌展示