Zendframework-mysql注入如何保护

| 如果我使用例如在ZF中插入,更新我会安全吗(mysql注入)? 例如代码的一部分:
            $data = array(
                \'autor\' => $autor,
                \'title\' => $title,
                \'text\' => $text,
                \'date\' => $date,
            );
            $news = new News();
            $news->insert($data); // safe?
    
已邀请:
类似的问题在这里: 如何在Zend Framework中编程的应用程序中防止SQL注入攻击? 始终确保使用mysql_real_escape_string清理用户输入值     
我认为随您的便好。我的意思是使用PDO ext的优点之一是可以防止使用PHP而不是MySQL进行SQL注入来查询数据库。 这是来自devzone.zend.com的更多内容     
您的操作方式很好。但是要注意mysql-expressions。在那里,您应该使用一个“ 1”对象:
$data = array(
    \'author\' => \'John Doe\',
    \'title\' => \'Headline goes here\',
    \'text\' => \'The content...\',
    \'date\' => new Zend_Db_Expr(\'NOW()\') //  <--- use this for SQL-Expressions
);
$news = new News();
$news->insert($data);
    

要回复问题请先登录注册