[英]Column not found: 1054 Unknown column 'id' in 'where clause'
Good, I have a database already created; 好,我已经创建了一个数据库; and when making the model I specify the primary key with
$primaryKey = "idturnos";
当创建模型时,我用
$primaryKey = "idturnos";
指定主键$primaryKey = "idturnos";
but when searching with Turn enter code here:: where ('idturnos', $ id) -> first ();
但是当使用Turn搜索时,请在此处输入代码:: where
('idturnos', $ id) -> first ();
I get the following message 我收到以下消息
Column not found: 1054 Unknown column 'id' in 'where clause'
未找到列:1054“ where子句”中的未知列“ 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)
you know need to use where clause 你知道需要使用where子句
try these 试试这些
$actualizar = App\Turno::find(1);
$actualizar->nomb_turno = strtoupper($request->nomb_turno);
$actualizar->descri_turno = strtoupper($request->descri_turno);
$actualizar->update();
dd($actualizar);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.