zoukankan      html  css  js  c++  java
  • thinkphp5 数据库的原生查询

    //thinkphp的原生查询
    $sql = "select pid,url from destoon_ad where aid>3";
    $result = Db::query($sql);
    dump($result);

    ------------------------------------------------------------

    参数绑定

    $sql = "select pid,url from destoon_ad where aid>?";
    $result = Db::query($sql,[3]);

    ------------------------------------------------------------

    命名点位符绑定【推荐】

    $sql = "select pid,url from destoon_ad where aid>:aid";
    $result = Db::query($sql,['aid'=>3]);

    ------------------------------------------------------------

    //更新操作
    $sql = 'update destoon_ad set hits=hits+100 where aid=:aid';
    $result = Db::execute($sql,['aid'=>3]);

    ------------------------------------------------------------

    //新增操作
    $sql = 'insert into destoon_ad (pid,url,hits) value (:pid,:url,:hits)';
    $result = Db::execute($sql,['pid'=>10,'url'=>'www.baidu.com','hits'=>1000]);

    ------------------------------------------------------------

    //删除操作
    $sql = 'delete from destoon_ad where pid=:pid';
    $result = Db::execute($sql,['pid'=>10]);

  • 相关阅读:
    10.用户管理
    9.更新系统时间
    8.标准输入输出重定向
    7.文件压缩与find命令
    6.Linux文件的详细属性
    5.Linux基础命令
    4.Linux目录结构
    3.磁盘光驱挂载
    2.xshell连接
    javascript中的location的用法
  • 原文地址:https://www.cnblogs.com/my2018/p/8836717.html
Copyright © 2011-2022 走看看