批改状态:未批改
老师批语:
<?php
namespace sql;
use PDO;
class Db{
protected $pdo = null;
public function __construct()
{
$this->pdo =new PDO('mysql::host=127.0.0.1;dbname=php','root','root');
//var_dump($this->pdo);
}
public function select($table,$fields,$where){
$sql = 'SELECT '. $fields .' FROM '. $table .' WHERE ' . $where;
$stmt=$this->pdo->prepare($sql);
$stmt->execute();
//$stmt->debugDumpParams();
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
}
$sql = new Db();
echo '<pre>'. print_r($sql->select('staff','name','staff_id>1'),true) ; //这里echo print_r忘了点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号