YII 的安全性演示代码SQL

来源:互联网 发布:可用的数据接口 编辑:程序博客网 时间:2024/05/16 17:28
 /**     * SQL注入演示     */    public function sql_unsafe($id) {        $connection = Yii::app()->db;        $sql = "SELECT * FROM qi_cell WHERE id = {$id}";        $command = $connection->createCommand($sql);                // $command->bindParam(":id", $id, PDO::PARAM_STR);                $command->execute();    }        /**     * 防SQL注入演示     */    public function sql_safe() {        $connection = Yii::app()->db;        $sql = "SELECT * FROM qi_cell WHERE id = :id";        $command = $connection->createCommand($sql);                $command->bindParam(":id", $id, PDO::PARAM_STR);                $command->execute();    }

0 0