Baylor Rae' Sun Jul 18 12:07:51 -0400 2010

Subject: Remove slashes when pulling rows

I've been playing with phpactiverecord and it's a blast to work with, but when I pull my rows from the database it shows slashes behind quotes.

Is there a way to automatically remove slashes in the model?

- Baylor Rae'


Baylor Rae' Sun Jul 18 12:20:00 -0400 2010

This was my quick fix


class Article extends ActiveRecord\Model {

    static $getters = array('title', 'description');

    public function __call($name, $value) {
        if( preg_match('/^get_/', $name) ) {
            $name = str_replace('get_', '', $name);

            return stripslashes($this->read_attribute($name));
        }
    }
}
Kien La Mon Jul 19 20:37:37 -0400 2010

You likely have magic_quotes turned on. We don't do any escaping in php-activerecord since we use prepared statements.

(1-2/2)