class poll
{
private $db;
public function __construct($dbConnection)
{
$this->db = $dbConnection;
}
public function getPollData(){
$sql = "SELECT poll_question, yes, no FROM poll WHERE poll_id=1";
$statement = $this->db->prepare($sql);
$statement = execute();
$pollData = $statement->fetchObject();
return $pollData;
}
}
在我尝试在我的代码中运行此类后,它说我
致命错误:调用未定义的函数execute() 第21行的C:\ xampp \ htdocs \ poll \ models \ poll.php
我正在使用xampp并且无法理解为什么它不起作用。
答案 0 :(得分:1)
修改
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="test" ng-init="testValue = 0">
<label ng-bind="testValue | currency"></label>
<input style="display:block;" ng-model="testValue" type="number"/>
</div>
要
$statement = execute();
答案 1 :(得分:0)
应该是$ statement-&gt; execute();
class poll
{
private $db;
public function __construct($dbConnection)
{
$this->db = $dbConnection;
}
public function getPollData(){
$sql = "SELECT poll_question, yes, no FROM poll WHERE poll_id=1";
$statement = $this->db->prepare($sql);
$statement = $statement->execute(); // You miss the $statement var
$pollData = $statement->fetchObject();
return $pollData;
}
}