返回查询构造器cu......登陆

查询构造器curd

12019-05-03 13:50:07405

<?php

namespace app\index\controller;

use think\Db;

use PDO;


class Index

{

    //查询

    public function index()

    {

    $res = Db::table('class')->field('r_id,r_name,r_fen')->where('p_id','=',2)->order('r_fen','desc')->limit(3)->select();

    // ->where('r_fen','<',90)

    var_dump($res);

    }

    //添加

    public function insert()

    {

    $data = [

    ['r_name'=>'aaaa',

    'r_city'=>'1111a',

    'r_fen'=>'78',

    'p_id'=>2],

    ['r_name'=>'aaaa',

    'r_city'=>'1111a',

    'r_fen'=>'78',

    'p_id'=>2],

    ['r_name'=>'aaaa',

    'r_city'=>'1111a',

    'r_fen'=>'78',

    'p_id'=>2]

    ];

    dump($data);


    $res = Db::table('class')->data($data)->insertAll();

    // $id = Db::getLastInsID();

    return "添加".$res;


    }

    //删除

    public function dle()

    {

    $id = 14;

    Db::table('class')->delete($id);

    }

    //修改

    public function upl()

    {

    Db::table('class')->where('r_id',1)->data(['r_name'=>'杨俊杰','r_fen'=>100])->update();

    }

}


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送