繁体   English   中英

PHP Catchable 致命错误:无法将类 stdClass 的对象转换为字符串

[英]PHP Catchable fatal error: Object of class stdClass could not be converted to string

$SourceID = $this->source_information->SourceID;

// the following fails 

if($results = $this->mysqli->query("SELECT .... R.Name = '$release_name' AND S.SourceID = $this->source_information->SourceID  AND S.ReleaseID = R.ReleaseID"))

// this will works  
if($results = $this->mysqli->query("SELECT .... R.Name = '$release_name' AND S.SourceID =  $SourceID  AND S.ReleaseID = R.ReleaseID"))

我有大量带有 $this->source_information->SourceID 排序的代码,如果里面有东西,我真的不知道要重写它,告诉我我可以如何使它工作。

编辑如下:

退出(var_dump($this->source_information->SourceID));

返回(字符串(2)“18”)

感谢您提出准备好的声明。 从现在开始,我将使用准备好的语句。

简单的变量插值语法,即"$this->foo" ,最多只能解析一个嵌套对象。 "$this->foo->bar"被解释为$this->foo加上字符串"->bar" 这就是为什么它抱怨source_information对象。 如果要嵌入更深层次的嵌套对象,请使用复杂变量插值语法

"... S.SourceID = {$this->source_information->SourceID}  AND ..."

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM