博客列表 >pdo查询记录值-2018.08.30

pdo查询记录值-2018.08.30

雨天的博客
雨天的博客原创
2018年09月05日 08:51:14687浏览

实例

<?php
/**
 * Created by PhpStorm.
 * 查询记录值
 */
$pdo = new PDO('mysql:host=localhost;dbname=data','root','root');
//$sql = "select name,address,datetime from stu where id > :id";
//$stmt = $pdo->prepare($sql);
//$stmt->execute(['id'=>5]);
//echo $stmt->fetchColumn(0);
//echo $stmt->fetchColumn();//自动下移,只能获取某一行的某一列值,不能获取同行的数据
//echo $stmt->fetchColumn(2);
//echo '<br>';
$stmt = $pdo->prepare("select count(*) from stu where id > :id");
$stmt->execute(['id'=>8]);
echo  $stmt->fetchColumn();

运行实例 »

点击 "运行实例" 按钮查看在线实例


声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议