-2
可能重复:
pass constructor arguments using PDO::FETCH_CLASSTYPEPDO :: FETCH_CLASS和ctor_args
如何把参数的获取类对象的构造函数?
代码
$sth->setFetchMode(PDO::FETCH_CLASS, 'Fetch_class', ['method' => 'get']);
class Fetch_class extends fclass {
public function __construct($options=[]){
print_r($options);
}
}
class fclass {
}
结果
Array
(
)
有两个问题没有合适的解决方案 – clarkk
还有一个示例中的评论http://php.net/manual/de/pdostatement.setfetchmode.php – Gordon