0

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..

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.