dongyun7571 2013-11-01 18:05
浏览 68

mysql存储函数不能用于预处理语句(php)

I'm trying to create a sequence replacement in innoDB (since auto_increment behaves differently than in myisam). So i've created a stored function, named seq. I can use it as follows:

INSERT INTO a_table(id) VALUES(seq('seq_a_table'));

My mysqli based database library automatically uses prepared statements, so i get this error:

This command is not supported in the prepared statement protocol yet 

MySQL version: 5.1.48 (OSX snow leopard).

UPDATE

Wow, i feel stupid... i was so confused by the error that i missed the simple fact that it wasn't thrown by the statement in question. I was using transactions and forgot that my query function automatically compiles everything as statements, including "START TRANSACTION". So for future late night coders - do not try to start a transaction in a statement :)

  • 写回答

1条回答 默认 最新

  • dqfaom241360 2013-11-01 18:23
    关注

    why not just use the old mysql for that case. something like:

    $con = mysql_connect("192.168.x.x","host","pass");
    if (!$con) die('Could not connect: ' . mysql_error());
    mysql_select_db("yourdb", $con) or die("cannot select DB");
    
    mysql_query( "INSERT INTO a_table(id) VALUES(seq('seq_a_table'))" );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?