<?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();
点击 "运行实例" 按钮查看在线实例