What is the difference between mysql_real_query
and mysql_query
? I've made a quick google search but could not find any link that shows the difference between the two.
mysql_real_query vs mysql_query [关闭]
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- doulou1989 2011-09-20 14:33关注
mysql_real_query() doesn't exist in PHP. However, mysqli_real_query() exists.
According to the official MySQL manual (the C API): http://dev.mysql.com/doc/refman/5.0/en/mysql-real-query.html
mysql_query() cannot be used for statements that contain binary data; you must use mysql_real_query() instead. (Binary data may contain the “\0” character, which mysql_query() interprets as the end of the statement string.) In addition, mysql_real_query() is faster than mysql_query() because it does not call strlen() on the statement string.
About your second issue, the best way to insert multiple records is to create an INSERT query with multiple values:
INSERT INTO table (col1, col2) VALUES (1, 1), (2,2), (3,3)
And so on. This will insert all the new rows in 1 operation, so it should be faster than running 3 queries, one per each row.
PS: You should consider using an extension that supports prepared statements, like MySQLi (note the i) or, even better, PDO. Not only prepared statements are safer (if you use them correctly, they're 100% safe against SQL injections), but also let you do things like those you see in the examples in this page: http://fr2.php.net/manual/en/pdo.prepare.php (you can do that with INSERT queries as well, of course). Ah, and PDO is also object-oriented, which is nice :)
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 基于卷积神经网络的声纹识别
- ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
- ¥100 为什么这个恒流源电路不能恒流?
- ¥15 有偿求跨组件数据流路径图
- ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
- ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
- ¥15 CSAPPattacklab
- ¥15 一直显示正在等待HID—ISP
- ¥15 Python turtle 画图
- ¥15 stm32开发clion时遇到的编译问题