1: $command = Yii::app()->db->createCommand('CALL sp_MyStoredProcedure (
2: :v_id,
3: :v_createBy,
4: :v_title )');
5: $command->bindValue('v_id', NULL);
6: $command->bindParam('v_createBy', Yii::app()->user->id);
7: $command->bindParam('v_title', $_POST['Title']);
8: $result = $command ->execute();
Finally, I can insert/update a form data into MySQL database successfully.
And I have to try another 2 things
1. get result from Stored-Procedure. (get 'LAST_INSERT_ID()' in Inserting case and get the number '1' in Updating Case, otherwise get the number '-1' to mean failed.)
2. package the result and the message into JSON format and response back to the front-end. It's supposed to follow Yii framework's style.
No comments:
Post a Comment