Welcome Guest, Not a member yet? Register   Sign In
Multiple primary keys for protected $primaryKey
#4

It's a good question if you're asking how to set up Model::primaryKey to support a multi-column primary key. The answer is: you cannot. The value assigned to Model::primaryKey must be the name of a single column. However, the column used need not be the actual PRIMARY key for the table. The property can use any column, but that column should contain unique values and ideally be indexed.

You could probably extend the Model class to handle a composite primary key. That would require overriding five or six functions to achieve the same functionality.

One of the best features of CI4 is its use of namespace and autoloading which makes it much easier to extend any class.
Reply


Messages In This Thread
RE: Multiple primary keys for protected $primaryKey - by dave friend - 10-06-2019, 09:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB