我正在从NetTuts学习 PDO,到目前为止,我已经成功地根据字符串搜索 FETCH_ASSOC。
问题:PDO::
按整数搜索需要哪个?我以为是PDO::Fetch_OBJ
。以下返回错误。
$busid = $this->sanitize($string);
$database->query('SELECT name, address FROM business_information WHERE id = :id', array(':id' => $busid));
var_dump($database);
if($database->count() >= '1') {
$results->setFetchMode(PDO::FETCH_OBJ);
while($row = $results->fetch()) {
$test = "Name: ".$row['name']." Address: ".$row['address'];
}else{
$test = "no results were found";
}
var_dump 返回:
对象(数据库)#1 (7) {["pdo":"database":private]=> object(PDO)#2 (0) { } ["port"]=> int(3306) ["statement"] => object(PDOStatement)#6 (1) { ["queryString"]=> string(61) "SELECT name, address FROM business_information WHERE id = :id" } }