Save/Create Table Entry

Login or register to post comments
2 replies [Last post]
LaCeja's picture
Offline
Joined: 11/04/2009

I know I should already know this, but I don't.

I'm trying to insert a new row into a table, using the save method of the metacontrol class. How do I get the auto_increment key of the row just inserted? That auto_increment primary key is the only unique reference I will have to retrieve the row. Does the metacontrol save function return it? My save is returning NULL.

Sorry for the dumb question. I suppose it should be obvious!

Thanks in advance.

LaCeja

alex94040's picture
Offline
Joined: 11/06/2008

If the metacontrol is for the Person object, the ID will be here after you call Save():

$this->mctPerson->Person->Id

LaCeja's picture
Offline
Joined: 11/04/2009

Thanks Alex. I was assuming the save would return the Id of the new row, because I was looking at the "return" in the model.

$intNewId = $this->mctPerson->Save();

Now, it works perfectly. Maybe I'd better take a day off!

Thanks again,

LaCeja