P
P
Pavel Gogolinsky2014-01-26 11:37:46
Yii
Pavel Gogolinsky, 2014-01-26 11:37:46

How in Yii, using Active Record, before writing to the database a string with quotes inside, escape these quotes?

How in yii, using Active Record, before writing to the database a string with quotes inside, escape these quotes?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
OnYourLips, 2014-01-26
@OnYourLips

It's already out of the box. You don't need to do anything extra.

R
Ruslan Kasymov, 2014-01-26
@HDAPache

in the model

protected function beforeSave()
{
    if (parent::beforeSave() === false)
        return false;
    $this->you_attribute = addslashes($this->you_attribute);
    return true;
}

Where you_attribute is your form field
. But, as far as I understand, the protection against SQL injections in the save() method is already implemented;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question