致命错误:在非对象上调用成员函数 FetchRow() [英] Fatal error: Call to a member function FetchRow() on a non-object
问题描述
这是我的错误信息致命错误:在第 749 行的 C:\AppServ\www\hfix\include\care_api_classes\class_mini_dental.php 中的非对象上调用成员函数 FetchRow()
这是代码:
if ($cc=='0'){$cc='1';} else{$cc='0';}
$this->sql='SELECT `encounter_nr`,`article_item_number`,`dosage`,`price` FROM `care_encounter_prescription` WHERE `bill_status` = "archived" AND `prescribe_date` = "'.$dt.'" ORDER BY encounter_nr ASC ';
$this->result=$db->Execute($this->sql);
$this->sql='SELECT DISTINCT(`encounter_nr`) FROM `care_encounter_prescription` WHERE `bill_status` = "archived" AND `prescribe_date` = "'.$dt.'" ORDER BY encounter_nr ASC ';
$this->newquery=$db->Execute($this->sql);
$patients = $this->newquery->RecordCount();
while($this->zrow = $this->result->FetchRow()){
$this->sql = 'SELECT `unit_cost` FROM `care_tz_drugsandservices` WHERE `item_id` = '.$this->row[1];
$this->lastquery=$db->Execute($this->sql);
if ($vx = $this->lastquery->FetchRow()) $cost = $vx[0];
else $cost = 0;
$costs += $this->row[2] * $cost; # dosage * cost
$income += $this->row[2] * $this->row[3]; # dosage * price
} }
推荐答案
假设文件 C:\AppServ\www\hfix\include\care_api_classes\class_mini_dental.php
的第 749 行是指这个在您的示例中的行...
Assuming line 749 of the file C:\AppServ\www\hfix\include\care_api_classes\class_mini_dental.php
is referring to this line in your example...
if($this->row=$this->result->FetchRow()){
那么你的问题是 $this->result
不是一个对象.您将 $this->result
分配给前一行,返回值是 $db->Execute($this->sql)
.因此,如果 $db->Execute()
返回对象以外的任何内容,您将收到该错误.我的猜测是 $db->Execute()
由于某种原因未能执行您的查询并返回 boolean
false
或其他一些非对象值作为失败的指示.你应该先检查返回值是否有错误,然后再像这样盲目使用.
Then your problem is that $this->result
is not an object. You assign $this->result
on the previous line with the return value of $db->Execute($this->sql)
. So if $db->Execute()
returns anything other than object you would get that error. My guess is $db->Execute()
failed to execute your query for one reason or another and return a boolean
false
or some other non-object value as indication of failure. You should check the return value for errors first before blindly using it like this.
另见https://stackoverflow.com/a/12769983/1878262 [相关]
这篇关于致命错误:在非对象上调用成员函数 FetchRow()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!