$id_program_= DB::table('Programs')->select('id_Program')
->where("name","=",$row['name'])
->first('id_Program')->id_Program
Erro: Trying to get property 'Program_id' of non-object
$id_program_= DB::table('Programs')->select('id_Program')
->where("name","=",$row['name'])
->first('id_Program')->id_Program
Erro: Trying to get property 'Program_id' of non-object
If, as it seems, you want to get the value of a column only ( id_Program
).
The documentation says the following in the section entitled: Retrieving A Single Row / Column From A Table :
If you do not even need a full row, you can extract a single value of a record using the
value
method. This method will return the value of the column directly:$email = DB::table('users')->where('name', 'John')->value('email');
So, to get the value of the id_Program
column, you can do this simply:
$id_program_= DB::table('Programs')->
->where('name',$row['name'])
->value('id_Program');
$id_program_= DB::table('Programs')->select('id_Program')<br/>
->where("name","=",$row['name'])<br/>
->first();
To get the result it would be $id_program->id_Program;
You can try this.
$sql= DB::table('Programs')
->select('id_Program')
->where("name","=",$row['name'])
->get();
$id_Program = $sql->first()['id_Program'];