Sep.28

Insert Function in Symfony (How to save data of Form in to symfony)

INSERT_QUERY

We Can inset the relevant data sent from the form or any other refrence data like system date, author id from session variable.
First we need to know how to get the content of form in Model class.
The function Signature of Symfony is :
public function executeSaveCms(sfWebRequest $request) {
}
Here we can get the post or get request in this above function.
Get Request :

$request->getParameter(‘editId’);
/* Here editId is get request which is sent from browser*/

Post Request :
$request->getPostParameter(‘ContentTitle’);
/* Here contentTitle is input fields name form */
The request is assign in intermediate variable;
$content = $request->getPostParameter(‘ContentTitle’);

$c = new TBLCMS();
/* Create object for inserting table content Table name TBLCMS */
$c->setId(“”);
$c->setName($pharmacySeqNo);
/* These below are the column name which set the content for the relevant column name */
$c->setContentTitle($content);
/* The ContentDescription is column name which is CONTENT_DESCRIPTION*/
$c->setContentDescription($desc);
$c->setInsertedDate(date(‘d-m-Y’));
$c->setInsertedBy($userId);
$c->setStatus(‘A’);
$c->save();
/*Finally we have to set the object to save function it will run the query with above relevent fields */

Share this Story:
  • facebook
  • twitter
  • gplus

Leave a comment

Facebook Comment