thinkphp5.0
sublime
1、tp5.0支持数据库类型 Mysql、SqlServer、PgSQL、Sqlite等数据库
3、查询数据 tp方法 //实例化系统数据库类 $Db = new Db; $data = $Db::table('user')->select(); sql语句 //实例化系统数据库类 $Db = new Db; $data = $Db::query(“select * from user”);
4、数据库的基本使用 查询 Db::query(“select * from user”); Db::query(“select * from user where id>=? and id<=?”,[2,6]); 增加 Db::execute('insert into user value(null,'name','password')'); Db::execute('insert into user value(null,?,?)',['name','password']); Db::execute('insert into user value(null,:name,:password)',['name'=>'zhangsna','password'=>'123']); 删除 Db::execute('delete from user where id>10); Db::execute('delete from where id>?',[10]); Db::execute('delete from where id>:id',['id'>=10]); 修改 Db::execute('update user set age=10 where id=1);
5、视图查询 Db::view('User','id,name') ->view('Profile','truename,phone,email','Profile.user_id=User.id') ->view('Score','score','Score.user_id=Profile.id') ->where('score','>',80) ->select();
使用类时,一定要引用类