zoukankan      html  css  js  c++  java
  • pdo预处理

     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2 <html xmlns="http://www.w3.org/1999/xhtml">
     3 <head>
     4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     5 <title>无标题文档</title>
     6 </head>
     7 
     8 <body>
     9 <?php
    10 
    11     //造PDO对象
    12     $pdo = new PDO("mysql:dbname=mydb;host=localhost","root","123");
    13     
    14     //写SQL语句
    15     $sql = "insert into Info values(?,?,?,?,?)";
    16     
    17     //准备SQL语句
    18     $st = $pdo->prepare($sql);
    19     
    20 /*    //给SQL语句分配变量
    21     $st->bindParam(1,$code);
    22     $st->bindParam(2,$name);
    23     $st->bindParam(3,$sex);
    24     $st->bindParam(4,$nation);
    25     $st->bindParam(5,$birthday);
    26     
    27     //给变量赋值
    28     $code = "p120";
    29     $name = "接口";
    30     $sex = true;
    31     $nation = "n002";
    32     $birthday = "1988-2-3";
    33     
    34     //执行SQL语句
    35     $st->execute();
    36     
    37     */
    38     
    39     //执行SQL语句,简便方法
    40     $st->execute(array('p030','克隆',true,'n001','1989-2-3'));
    41     
    42     
    43     
    44     
    45     
    46 ?>
    47 </body>
    48 </html>
  • 相关阅读:
    领域驱动设计概览
    淘宝大秒系统设计详解
    如何设计测试用例
    MySQL性能优化
    Nginx 负载均衡
    智慧园区该怎么建设
    Docker容器完整使用教程
    C#框架结构分层
    项目验收PPT
    这么少的字,也能做出这么好看的PPT
  • 原文地址:https://www.cnblogs.com/crazy-zw/p/5372194.html
Copyright © 2011-2022 走看看