Reputation: 3063
in my project i want to add comments to each post. For inserting comments i am using ajax. since INSERT statements are not allowed in DQL. How can i insert comments using ajax. any one please help me. thanks in advance..
Upvotes: 0
Views: 619
Reputation: 34107
Create a new comment object, fill it with values, then save it.
$c = new Comment();
$c->fromArray($request->getParameter("comment"));
$c->save();
This is the easiest way. But you should be using a form, so it's also validated:
$f = new CommentForm();
$f->bind($request->getParameter($f->getName()));
if ($f->isValid()) {
$f->save();
}
See the form framework documentation for more info.
Upvotes: 2