设为首页 加入收藏

TOP

PHP PDO操作MYSQL(五)
2017-10-10 08:32:36 】 浏览:5983
Tags:PHP PDO 操作 MYSQL
p;   /* $insert->execute(array(null,'凯撒','caesar@gmail.com','90',$time)); */

    $insert->execute(array(null,'凯撒','caesar@gmail.com','90',$time));

    $count=$insert->rowCount();

    echo "<br />查询执行完毕!改变的行数为:".$count;

$sql=null;

?>

      

       命名参数绑定方式代码如下:

<?php

        header('Content-Type:text/html; charset=utf-8');

        require 'config.php';

 

        $sql="INSERT INTO grade (id,name,email,point,regdate) VALUE (:id, :name, :email, :point, :regdate)";

        $insert=$DB->prepare($sql);

        $time=date('Y-m-d H:i:s',time()+(8*60*60));

       

        //第一种绑定方式

        /* $insert->bindValue("id", null);

        $insert->bindValue("name", 'caesar');

        $insert->bindValue("email", 'caesar@gmail.com');

        $insert->bindValue("point", 60);

        $insert->bindValue("regdate", $time); */

       

        //第二种绑定方式

        /* $insert->bindParam("id", $id);

        $insert->bindParam("name", $name);

        $insert->bindParam("email", $email);

        $insert->bindParam("point", $point);

        $insert->bindParam("regdate", $regdate);

        $id=null;

        $name="凯撒";

        $email="caesar@e.com";

        $point=65;

        $regdate=$time; */

       

        //第三种绑定方式

        $insert->execute(array('id'=>null,'name'=>'alice','email'=>'alice@e.com','point'=>90,'regdate'=>$time));

        $count=$insert->rowCount();

        echo "<br />查询执行完毕!改变的行数为:".$count;

        $sql=null;

?>

 

预处理批量查询,分别采用2种占位符,代码如下:

<?php

        header('Content-Type:text/html; charset=utf-8');

        require 'config.php';

        $DB-

首页 上一页 2 3 4 5 6 7 8 下一页 尾页 5/11/11
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇电话号码格式化 下一篇用数组指针遍历数组,FOR/FOREACH..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目