Solved: $model->save() is not fired, no log, no error, no insert

I have a problem - hope someone has a solution

I am calling a private function in the controller itself before moving to model: Expecting to insert and return the InsertId. I need the InsertId or UpdateId back to maintain other tables.


    private function CreateEvent($e) {


        //$event = new Event;






        $id = $event->save(); echo "<pre>CreateEvent $id";

        //print_r($event); die;


It does not give me error. all SQLs shows in runtime log EXCEPT for insert.

My AR reads but does not do any DML.

Part of the log:

2009/07/02 01:37:55 [trace][][system.db.CDbCommand][system.web.CModule][system.web.filters.CFilterChain][system.db.CDbConnection]  Executing SQL: DELETE FROM ae_session WHERE expire<1246516675

2009/07/02 01:37:55 [/s][/s][/s][/s][/s][trace][][system.db.CDbCommand][system.web.CModule][system.web.filters.CFilterChain][system.db.CDbConnection]  Querying SQL:

SELECT data FROM ae_session

WHERE expire>1246516675 AND id='5ca42f4b4e676cfae1da69305d3cb38e'

2009/07/02 01:37:55 [/s][/s][/s][/s][/s][trace][][system.db.CDbCommand][system.web.CModule][system.web.filters.CFilterChain][system.db.CDbConnection]  Loading "securityManager" application component

2009/07/02 01:37:55 [/s][/s][/s][/s][/s][trace][][system.db.CDbCommand][system.web.CModule][system.web.filters.CFilterChain][system.db.CDbConnection]  Loading "statePersister" application component[/s][/s][/s][/s][/s]

I think it's your model declaration:

It should look something like this:


$event = new Event;

$event -> attribute1 = $e -> whatever;

$event -> save();


I tried that too. I am using MySQL and innodb table.

Not working.

Check to see if there are any validation errors.

Don't forget returning true in the method.

 return true;

Thank you!

"return true;" did the trick

One last question, I would like to return PKey from $model->save(), be it Insert or Update.

What would be the Syntax? I tried looking for sample code in forum and site. 

override save() and return the PK you want ?

Thank you qiang

I see what you are saying, after save, return $model->id