该函数是$this
的一部分,它传入一个带有一些?
标记的MySQL查询。通过执行填充参数,并将结果加载到单独的对象中。这个对象(请求脚本)是否需要在 runSelect()
中传递,并且 $STH
确实需要存在吗?或者可以将其转换为 的一部分>$这个
?
public function runSelect($query, $param, $obj){
try {
$STH = $this->dbh->prepare($query);
$STH->setFetchMode(PDO::FETCH_INTO, $obj);
$STH->execute($param);
$STH->fetch();
} catch(PDOException $e) {
echo $e->getMessage();
}
return($obj);
}
最佳答案
Does this object (requesting the script) need to be passed in the runSelect()
没有。
does $STH really need to exist
是的。
can it be translated to a part of $this?
是的。
关于php - PHP 中的 PDO 过于复杂?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8498121/