如何通过[self.parentViewController.view addSubview:mySubview];
执行在PDOStatement类中设置 readonly $queryString
属性?
鉴于类定义,我没有看到任何设置该查询的函数。这是否意味着PDOStatement类不能通过PDO::prepare()
函数由PDO类实例生成?
答案 0 :(得分:1)
PDOstatement is created internally, by means of C code. And of course C code can set any properties directly.
And yes, you cannot use PDOStatement class (for anything useful) if it's not generated by the PDO class instance through PDO::prepare()
(or query()
).
However, you can redeclare and tell PDO to use it instead of standard one using code like this
$pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, ['myPDOStatement', [$pdo]]);
答案 1 :(得分:0)
来自manual:
言
<小时/> [PDOStatement类]表示预准备语句,并在执行语句后生成关联的结果集。
这看起来必须由PDO::prepare()
创建。
但这是一个问题吗?我不能说我遇到了想要手动创建PDOStatement对象的情况。