Posts tagged with ‘php 5’

Symfony: Control Model->save() function to perform INSERT or UPDATE

advertisement

In Symfony Framework, Model->save() function is clever enough to determine to use INSERT or UPDATE for the query. But i’ve tried many ways to perform an UPDATE for my record but failed. It keep INSERT new record. Finally i found the solution to control the Model->save() function to perform INSERT or UPDATE.

Just a simple example:-
Assume there is a User table where ID is the primary key, and there is a user record with id = 5, now we perform the code below, it should be smart enough to perform UPDATE but NO!, the code below will INSERT a new record.

Continue reading Symfony: Control Model->save() function to perform INSERT or UPDATE »