CakePHP - Primary key issue, How to override default 'id' field as Primary Key

StackOverflow https://stackoverflow.com/questions/21554194

  •  06-10-2022
  •  | 
  •  

Вопрос

CakePHP uses 'id' as primary key. How can I override this limitation.

I have data_base with primary key as doc_it, and I am using save() for updating the records.

I have check previous threads, but wasn't able to fix the issue.

Это было полезно?

Решение

You can mention below code in your Model

public $primaryKey = 'doc_it';

and then you can use $this->YourModel->id; in your controller to access the primary key.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top