从空值创建默认对象 [英] Creating default object from empty value
问题描述
我正在我的代码中实现PDO。这就是我做的方式,我在第221行收到错误信息为...... HipHop警告:在第221行的/var/www/webApp/services/CurrencyService.php中从空值创建默认对象。请检查并确认我哪里出错。
公共功能getExchangeRate($ curr){
$ stmt = $ this-> vConnection-> prepare(SELECT rate FROM $ this-> tablename where curr =?);
$ this-> throwExceptionOnError();
$ stmt-> bindparam(1,$ curr);
$ this-> throwExceptionOnError();
$ stmt-> execute();
$ this-> throwExceptionOnError();
$ stmt-> bindColumn(1,$ row-> rate); //第221行
if($ row = $ stmt-> fetch()){
返回$ row;
} else {
返回null;
}
}
i am implementing PDO in my code . this is how i did it ,i am getting an error message on line 221 as ...HipHop Warning: Creating default object from empty value in /var/www/webApp/services/CurrencyService.php on line 221 . please check and verify where i am going wrong.
public function getExchangeRate($curr) {
$stmt = $this->vConnection->prepare("SELECT rate FROM $this->tablename where curr=?");
$this->throwExceptionOnError();
$stmt->bindparam(1, $curr);
$this->throwExceptionOnError();
$stmt->execute();
$this->throwExceptionOnError();
$stmt->bindColumn(1, $row->rate); //line 221
if($row = $stmt->fetch()) {
return $row;
} else {
return null;
}
}
推荐答案
curr){
curr) {
stmt =
this-> vConnection-> ;准备(SELECT rate FROM
this->vConnection->prepare("SELECT rate FROM
这篇关于从空值创建默认对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!