Php 未找到列:“where子句”中的1054未知列“id”
很好,我已经创建了一个数据库;在制作模型时,我用 $primaryKey=idturnos;但在使用Turn搜索时,请在此处输入代码::where'idturnos',$id->first; 我得到以下信息Php 未找到列:“where子句”中的1054未知列“id”,php,model,laravel-5.8,Php,Model,Laravel 5.8,很好,我已经创建了一个数据库;在制作模型时,我用 $primaryKey=idturnos;但在使用Turn搜索时,请在此处输入代码::where'idturnos',$id->first; 我得到以下信息 未找到列:“where子句”中的1054未知列“id” 你知道需要使用where子句 试试这些 $actualizar=App\Turno::find1; $actualizar->nomb_turno=strtoupper$request->nomb_turno; $actualizar-
未找到列:“where子句”中的1054未知列“id”
你知道需要使用where子句 试试这些 $actualizar=App\Turno::find1; $actualizar->nomb_turno=strtoupper$request->nomb_turno; $actualizar->desci_turno=strtoupper$request->desci_turno; $SAR->更新; dd$南非兰特;
未找到列:“WHERE子句”SQL中的1054个未知列“ID”:从TurnS.ID=2限制发生的TUNS中选择*,因为它不认为我是自定义ID的名称,但是如果它再次保存,只需编辑它就会给我这个错误。而不是在何处使用方法查找方法,这样实例就会从模型变量中找到主键。我将看到如何解决它,感谢您的回答:
class Turno extends Model
{
//
public $table = 'turnos';
protected $PrimaryKey = "idturnos";
public $timestamps = false;
}
Controller:
$actualizar = App\Turno::where('idturnos', $id)->first();
$actualizar->nomb_turno = strtoupper($request->nomb_turno);
$actualizar->descri_turno = strtoupper($request->descri_turno);
enter code here $actualizar->save();
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: update `turnos` set `nomb_turno` = LOLA, `descri_turno` = XDA where `id` is null)