Answer the question
In order to leave comments, you need to log in
Yii2 how to escape data written to the database?
Example:
$message = new Messages();
$message->message = $this->message;
$message->save()
Answer the question
In order to leave comments, you need to log in
1) When writing data to the database using AR , the lines are escaped. Those. you won't have sql injection there.
You can clear tags in two ways:
1) when displayed in a view, for example:
2) Clear using Htmlpurify, in the beforeSave method, for example:
$this->content = HtmlPurifier::process($this->content) ;
Do whatever you want with the data, with the help of validators (I just didn't understand what you meant by "escaping").
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question