zoukankan      html  css  js  c++  java
  • curd——5

    SELECT area_id  FROM 16tree.ts_area  where pid=0;


    <?php
    //1可以防止注入
    $db = Yii::app()->db; //you have to define db connection in config/main.php
    $sql = "select sum(if(starttime>'09:00:00',1,0)) as late,sum(if(endtime<'18:00:00',1,0)) as early from present where userid=:userid and date between :date_start and :date_end";
    $results = $db->createCommand($sql)->query(array(':userid' => 115,':date_start'=>'2009-12-1',':date_end'=>'2009-12-31',));
    foreach($results as $result){
      echo $result['late']," and ",$result['early']," /n";
    }





    //2可以防止注入

    $oDbConnection = Yii::app()->db; // 获取数据库连接(config / main.php设置链接的数据库
    // 在这里,你将用你的复杂的SQL查询使用字符串或其他一的方式来创建查询
    $oCommand = $oDbConnection->createCommand('SELECT * FROM my_table WHERE myAttr = :myValue');
    // 绑定参数
    $oCommand->bindParam(':myValue', $myValueThatCameFromPostOrAnywereElse, PDO::PARAM_STR);
     

    $oCDbDataReader = $oCommand->queryAll(); // 运行查询并在cdbdatareader获得所有的结果
    ?>

  • 相关阅读:
    开启CTF大门
    关于windows下scapy出现log_runtime问题
    Python关于Threading暂停恢复解决办法
    angr入门之CLE
    Linux信号量
    IDApython 命令
    Array 数组对象
    随机数 random()
    四舍五入round()
    向下取整floor()
  • 原文地址:https://www.cnblogs.com/ldms/p/8317869.html
Copyright © 2011-2022 走看看