简体   繁体   English

未找到列:1054“ where子句”中的未知列“ id”

[英]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.

相关问题 找不到列:1054“ where子句”中的未知列“ id”-Laravel - Column not found: 1054 Unknown column 'id' in 'where clause' - Laravel 未找到列:1054 'where 子句'中的未知列'id' Laravel 5.6 - Column not found: 1054 Unknown column 'id' in 'where clause' Laravel 5.6 SQLSTATE [42S22]:找不到列:1054“ where子句” Id中的未知列“ id”为空 - SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' Id is null 1054 where子句中的未知列? - 1054 Unknown column in where clause? updateOrCreate()给出未找到的列:1054“ where子句”中的未知列“ 0” - updateOrCreate() gives Column not found: 1054 Unknown column '0' in 'where clause' 找不到列:1054'on子句中的未知列'locations.id' - Column not found: 1054 Unknown column 'locations.id' in 'on clause SQLSTATE [42S22]:找不到列:1054“ where子句”中的未知列“ answers.question_id” - SQLSTATE[42S22]: Column not found: 1054 Unknown column 'answers.question_id' in 'where clause' QueryException SQLSTATE [42S22]:找不到列:1054“ where子句”中的未知列“ customers.id” - QueryException SQLSTATE[42S22]: Column not found: 1054 Unknown column 'customers.id' in 'where clause' 如何解决 SQLSTATE [42S22]: Column not found: 1054 Unknown column 'id' in 'where 子句' - how to solve SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' SQLSTATE [42S22]:未找到列:1054 'where 子句'中的未知列'products.wishlist_id' - SQLSTATE[42S22]: Column not found: 1054 Unknown column 'products.wishlist_id' in 'where clause'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM