【问题标题】:Sql error: General error: 25Sql 错误:一般错误:25
【发布时间】:2018-09-09 18:10:30
【问题描述】:
$up = $this->db->prepare ("
        UPDATE ".self::DbUser." SET UserLogin=:UserLogin WHERE UserId=:UserId; 
        UPDATE ".self::DbUProfile." SET ProfileName=:ProfileName, ProfilePhone=:ProfilePhone WHERE ProfileUserId =:UserId");

$up->bindValue (':UserLogin', $UserLogin);
$up->bindValue (':ProfileName', $ProfileName);
$up->bindValue (':ProfilePhone', $ProfilePhone);
$up->bindValue (':UserId', $UserId);

if ( !$up->execute() )...

结果:一般错误:25 绑定或列索引超出范围

什么是问题?谢谢!

【问题讨论】:

  • 您不能一次执行多个查询。
  • @u_mulder 我也这么认为,但我发现一些信息说你可以,比如stackoverflow.com/questions/6346674/…
  • @Barmar 很有趣。那么问题应该是重复的userId占位符。
  • 是的,我怀疑就是这样。

标签: php sql sqlite pdo


【解决方案1】:

documentation for execute 说(通过this question 找到):

input_parameters 中的键必须与 SQL 中声明的键相匹配。在 PHP 5.2.0 之前,这被默默地忽略了。

尝试将查询一分为二,并为每个execute 仅指定使用的参数?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-25
    • 1970-01-01
    • 2014-03-24
    • 2012-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-20
    相关资源
    最近更新 更多