类 stdClass 的对象无法转换为字符串
public function get($id = null)
{
$terms = array('id' => $id);
$blog = $this->model->getBy($terms);
// $blog => (object) [id => 1, category_id => 3]
$fix->id = $blog->id;
// $fix->category = $this->getCategory($blog->category_id); // Not work
$fix->cat_or_something = $this->getCategory($blog->category_id); // Work
return $fix;
// $fix => (object) [id => 1, cat_or_something => [name => Some Category]]
}
如果我更改$fix->category
为$fix->cat_or_something
,它将起作用。有一些奇怪的东西$fix->category
。