doujing5937 2014-07-03 19:27
浏览 98

MySQLi Wrapper - 奇怪的where子句问题?

I am currently using joshcam's PHP-MySQLi-Database-Class which has quite a few stars and forks. However, even with all of the attention it gets, it seems like it's missing some features — or I am misunderstanding how to use it.

When I use the where clause function he created, the variables I input don't seem to have quotations around them. It's like I have to manually add the quotation marks to the beginning and end of the variables, even though they are prepared statements and that's counter intuitive.

I tried reaching him but no luck, so here I am.

Here's example code:

$db->where ('name', 'John Doe');
$results = $db->get ('users');
echo $db->getLastQuery();

Yet, here is what it outputs:

SELECT * FROM users WHERE name = John Doe

So unless I am missing something (and I carefully scanned the documentation), I am going to have to put quotes around every single variable in the where function? Why did he not incorporate this and why do so many people like this wrapper if such an obvious feature is missing? The whole benefit of prepared statements is that they handle the quotations and everything, so this is counter intuitive if I am doing it correctly.

EDIT: To take it one step further. On his documentation under the "Where" clause bit, it says:

OR CASE

$db->where ('firstName', 'John'); $db->orWhere ('firstName', 'Peter');
$results = $db->get ('users');
// Gives: SELECT * FROM users WHERE firstName='John' OR firstName='peter'

Yet when I place that exact code into my file and echo out the query, it shows no quotation marks still.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP