Welcome Guest, Not a member yet? Register   Sign In
It is required that the primary_key be called "id"?
#1

I was doing a simple crud with ci4 and everything went very well until I noticed that to eliminate some element of a table from the forced field table the primary_key has to be called "id"


This is the function that I use to eliminate

elimination of public functions ($ key) {
$ this-> crud_model-> delete ($ key);
return redirect () -> to ("/ crud");
}

When I see the error between a system / Model.php and I see that there is a global variable called primaryKey with "id" as the default value.

My question is, what should I do to be able to use that function without my primary key field being called "id"?

Excuse me for my english, greetings from Cuba
Reply
#2

If your table has a different primary key, then set the value of $primaryKey in the Model class that you're using (i.e. UserModel) and it should all work fine.
Reply
#3

(08-19-2018, 10:42 AM)kilishan Wrote: If your table has a different primary key, then set the value of $primaryKey in the Model class that you're using  (i.e. UserModel) and it should all work fine.

oh thank you very much, by the way that is in the documentation? in case it was not good that this. I asked the question because I am developing a lib of Crud generator for ci4 ..
Reply




Theme © iAndrew 2016 - Forum software by © MyBB