mysql PDO SET语句遇到错误
我正在寻找与 mysql 查询相关的东西,我偶然发现了这个链接 mysql 变量用法 并看到了类似存储过程的变量设置。我在 phpmyadmin 中尝试过:
SET @value = 5; 选择@rank;
它正在工作,但是当我尝试将它放在 PDO 语句中时,它不起作用。
$value = "SET @value = 0";
$stmt = $this->_dbHandle->prepare($value);
$stmt->execute();
请指导我做错了什么。
I was looking for something that is related to a mysql query and I stumbled to this link mysql variable usage and saw the stored proc-like variable setting. I've tried it in phpmyadmin :
SET @value = 5;
SELECT @rank;
and it is working, but when I tried to place it in PDO statements, it does not work.
$value = "SET @value = 0";
$stmt = $this->_dbHandle->prepare($value);
$stmt->execute();
Kindly guide on what I am doing wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到答案了,我的测试环境是使用sqlite。我在测试浏览器而不是 phpunit 测试装置中运行了我的查询,它确实有效。对不起,伙计们,错过了测试环境的引导。
Found the answer, my test environment is using sqlite. I've run my query in a test browser rather than in a phpunit test fixture and it did work.sorry guys, miss leaded by the test environment.