• php Tp5下mysql的增删改查


        //
        public function insert(){
            $data = array(
                "username"=>"user121",
                "password"=>"123456"
            );
            $code=Db::table('user')->insertGetId($data);
            dump($code);
        }
        
        //
        public function delete(){
            $where = array(
                'id' =>17
            );
    //        $code=Db::table('user')->where('id>38 and id<40')->delete();
            $code=Db::table('user')->where($where)->delete();
            dump($code);
        }
        
        //
        public function update(){
            $data = array(
                'username' => 'fsadfsaf'
            );
            $where = array(
                'id' =>18
            );
            $code=Db::table('user')->where($where)->update($data);
            dump($code);
        }
        
        //
        public function select(Request $request){
            $where = 'id < 18';
            $field = 'username,password';
            //查询所有数据
             $data=Db::table('user')->field($field)->where($where)->select();
            dump($data);
    }

    in 查询 和like 查询 

    in 查询

    public function index(){
            $arr = array('xuzhan','user','user2','user3','user4');
            $result=Db::table("user")->where('username',"in",$arr)->select();
            dump($result);
        }

    like 查询

    public function index(){
        $user = '%user%';
            $result=Db::table("user")->where('username',"like",$user)->select();
            dump($result);
        }

     where 多条件查询 

                $where['username'] = ['=',$param['username']];
    #$where['字段名'] = array('运算符','条件');
    $where['password'] = ['=',$param['password']]; $field = 'id'; //查询所有数据 $data=Db::table('user')->field($field)->where($where)->select(); var_dump($data);

  • 相关阅读:
    CLOUD COMPUTING MADE EASY by Cary Landis and Dan Blacharski
    浅析JSONP
    Xpages 执行的生命周期
    LotusScript类的继承
    苹果公司的UI交互设计师Bret Victor演讲 Inventing on Principle
    ajax
    Aptana 汉化方法
    删除数据库连接脚本
    让Visual Studio 也支持JS代码折叠 [ Visual Studio | #region | #endregion ]
    power designer简单教程
  • 原文地址:https://www.cnblogs.com/paopao123/p/10749015.html
Copyright © 2020-2023  润新知