MySQL如何知道什么是必需的 [英] How to know when escape is necessary for MySQL

查看:125
本文介绍了MySQL如何知道什么是必需的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CodeIgniter构建一个网站。这是我自己建立的与数据库进行交互的第一个站点。我在这个项目中使用MySQL。如何将数据保存到数据库之前如何进行转义?

解决方案

如果您使用数据库类查询绑定,您不需要执行任何手动转义:


使用绑定
的次要优点是值被自动
转义,从而产生更安全的查询。你
不必记得手动
转义数据;引擎为您自动执行



I'm in the process of building a site with CodeIgniter. This is the 1st site that I've built myself that interacts with a database. I'm using MySQL for this project. How can I tell if data needs to be escaped before saving it to the database?

解决方案

If you're using the database class with query bindings, you don't have to do any manual escaping:

The secondary benefit of using binds is that the values are automatically escaped, producing safer queries. You don't have to remember to manually escape data; the engine does it automatically for you.

这篇关于MySQL如何知道什么是必需的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆