Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 错误:类stdClass的对象无法转换为int_Php_Laravel - Fatal编程技术网

Php 错误:类stdClass的对象无法转换为int

Php 错误:类stdClass的对象无法转换为int,php,laravel,Php,Laravel,我有这个密码 $tempid = DB::table('local_founders')->select('entry_by')->where('founder_id', $id)->get(); if($tempid[0] != Auth::user()->id){ return Redirect::to('founder')->with('messagetext','Record Not Found !')->with('ms

我有这个密码

    $tempid = DB::table('local_founders')->select('entry_by')->where('founder_id', $id)->get();

    if($tempid[0] != Auth::user()->id){
      return Redirect::to('founder')->with('messagetext','Record Not Found !')->with('msgstatus','error');
     }
但这会导致以下错误:

类stdClass的对象无法转换为int

返回集合,如果需要第一个元素,请更改为:

$temp = DB::table('local_founders')->select('entry_by')->where('founder_id', $id)->first()
现在$temp是一个stdClass,之后您可以像其他stdClass对象一样轻松访问它,如下所示:
$temp->entry\u by

因此,我认为您必须按如下方式更改代码:

   $local_founder = DB::table('local_founders')->select('entry_by')->where('founder_id', $id)->first();
    if($local_found->entry_by != Auth::user()->id){return Redirect::to('founder')->with('messagetext','Record Not Found !')->with('msgstatus','error');}

什么是$id??你能显示dd($id)?你能显示dd($tempid)@Davit它的整数结果是“269”@MD.JubairMizan结果是数组:1[▼ 0 => {#900 ▼ +“entry_by”:10}]在您的dd($local_founder->entry_by)的问题输出中更新此信息;?[▼ 0 => {#900 ▼ +“entry_by”:10}]奇怪,这是一个数组!你确定你执行了
dd($local\u founder->entry\u by)
而不是
dd($local\u founder)
?谢谢艾哈迈德,现在没问题了,我运行了旧代码,现在可以用了
   $local_founder = DB::table('local_founders')->select('entry_by')->where('founder_id', $id)->first();
    if($local_found->entry_by != Auth::user()->id){return Redirect::to('founder')->with('messagetext','Record Not Found !')->with('msgstatus','error');}