Esempio n. 1
0
 public function mysql($urlInfo)
 {
     $d = new Demo();
     $d->id = $urlInfo['params'][1];
     $d->prop = intval($urlInfo['params'][2]);
     //新增举例
     echo AiMySQL::insert($d) ? "插入成功<br>" : "没有插入<br>";
     //修改举例
     $d->prop = rand(0, 99999);
     echo AiMySQL::update($d) ? "修改成功<br>" : "没有修改<br>";
     //删除举例
     echo AiMySQL::delete($d) ? "删除成功<br>" : "没有删除<br>";
     //实体查询举例
     $c[] = new AiMySQLCondition('id', '=', "123yfds");
     $c[] = new AiMySQLCondition('prop', '=', 60919);
     //select * from demo where id = "123yfds" and prop = 60919 order by id desc limit 2 , 5
     $rs = AiMySQL::queryEntity('Demo', $c, AiMySQLCombination::COMB_AND, 'id', AiMySQLOrderBy::DESC, 5, 2);
     if (false !== $rs) {
         foreach ($rs as $demo) {
             var_dump($demo);
             echo "<br>";
         }
     }
     //任意查询举例
     $sql = 'select distinct id "主键", count(*) "个数" from fm_demo group by id desc ';
     $rs = AiMySQL::queryCustom($sql);
     foreach ($rs as $r) {
         echo $r['主键'] . ' => ' . $r['个数'] . '<br>';
     }
 }
Esempio n. 2
0
 private static function test()
 {
     if (false !== @($sql = AiSQL::getSqlExpr('getQuery'))) {
         $rs = AiMySQL::queryCustom($sql);
     } else {
         echo "获取sql语句失败";
     }
     $list = AiMySQL::queryCustomByParams(AiSQL::getSqlExpr('getBookSell'), array('leftuser' => $user->id, 'rightuser' => $user->id));
     var_dump($list);
 }