SQLSTATE[HY093] 错误但数组长度相同

SQLSTATE[HY093] error but arrays are the same length

有一个问题,PDO 给我一个异常,说参数未定义。但是,我提供给它的两个数组肯定具有相同的长度和键,所以有什么问题吗?

您可以在下面看到函数,然后是更新查询,然后是正在发送的数组。 52是每部分的长度,下面是异常文本。

public function query($sql,$data,$read) {

    if (!($query = $this->connection->prepare($sql))) { exception(implode(' ',$query->errorInfo()),intval($query->errorCode())); } 
    if (!($query->execute($data))) { exception(implode(' ',$query->errorInfo()),intval($query->errorCode())); }

    if ($read) { $result = $query->fetchAll(PDO::FETCH_ASSOC); $this->count_reads++; } else { $result = $query->rowCount(); $this->count_writes++; }       

    $query = null; return $result;    
}        

更新 objects_servers 设置 id = :id, info__enabled = :info__enabled, info__version = :info__version, info__title = :info__title, info__color = :info__color, info__contact = :info__contact, info__chunksize = :info__chunksize, info__downloadwait = :info__downloadwait, info__crypto__ciphers = :info__crypto__ciphers, info__crypto__salt-length = :info__crypto__salt-length, info__crypto__pbkdf2-algorithm = :info__crypto__pbkdf2-algorithm, info__crypto__pbkdf2-iterations = :info__crypto__pbkdf2-iterations, info__crypto__chunk-size = :info__crypto__chunk-size, info__email__hostname = :info__email__hostname, info__email__smtp-auth = :info__email__smtp-auth, info__email__auth-password = :info__email__auth-password, info__email__auth-username = :info__email__auth-username, info__email__from-address = :info__email__from-address, info__email__from-name = :info__email__from-name, info__email__port = :info__email__port, info__email__smtp-secure = :info__email__smtp-secure, info__email__bcc-address = :info__email__bcc-address, features__users__download-pages = :features__users__download-pages, features__users__file-encrypt = :features__users__file-encrypt, features__users__admin = :features__users__admin, features__server__email-validation = :features__server__email-validation, features__server__softlimit = :features__server__softlimit, features__server__publiclimit = :features__server__publiclimit, features__server__hourly-statistics = :features__server__hourly-statistics, features__server__actionlog = :features__server__actionlog, features__server__limit-alerts = :features__server__limit-alerts, features__server__sequential-contentfill = :features__server__sequential-contentfill, features__server__outgoing-email = :features__server__outgoing-email, features__server__multiple-accounts = :features__server__multiple-accounts, statistics__timed__#start = :statistics__timed__#start, statistics__timed__storage += :statistics__timed__storage, statistics__timed__bandwidth += :statistics__timed__bandwidth, statistics__timed__downloads += :statistics__timed__downloads, statistics__forever__storage += :statistics__forever__storage, statistics__forever__bandwidth += :statistics__forever__bandwidth, statistics__forever__downloads += :statistics__forever__downloads, limits__server__forever__storage = :limits__server__forever__storage, limits__server__timed__bandwidth = :limits__server__timed__bandwidth, limits__server__timed__downloads = :limits__server__timed__downloads, limits__server__timed-expire = :limits__server__timed-expire, limits__server__public-filecount = :limits__server__public-filecount, limits__server__public-filesize = :limits__server__public-filesize, limits__users__filesize = :limits__users__filesize, limits__users__filecount = :limits__users__filecount, limits__users__forever__storage = :limits__users__forever__storage, limits__users__timed__bandwidth = :limits__users__timed__bandwidth, limits__users__timed__downloads = :limits__users__timed__downloads 其中 id = 'DjvMb938gkH867d3';

{"id":"DjvMb938gkH867d3","info__enabled":"1","info__version":"0.0.1","info__title":"Development","info__color":"#007127","info__contact":"yeeeup","info__chunksize":"2097152","info__downloadwait":"10","info__crypto__ciphers" :"serpent:ctr","info__crypto__salt-length":"512","info__crypto__pbkdf2-algorithm":"sha512","info__crypto__pbkdf2-iterations":"5000","info__crypto__chunk-size":"1048576","info__email__hostname":"fun","info__email__smtp-auth":"1","info__email__auth-password":"nope","info__email__auth-username":"blah1","info__email__from-address" :"blah2","info__email__from-name":"Person","info__email__port":"587","info__email__smtp-secure":"tls","info__email__bcc-address":"blah3","features__users__download-pages":"1","features__users__file-encrypt":"1","features__users__admin":"0","features__server__email-validation":"0","features__server__softlimit":" 1","features__server__publiclimit":"0","features__server__hourly-statistics":"1","features__server__actionlog":"1","features__server__limit-alerts":"1","features__server__sequential-contentfill":" 0","features__server__outgoing-email":"0","features__server__multiple-accounts":"1","statistics__timed__#start":null,"statistics__timed__storage":"0","statistics__timed__bandwidth":"0" ,"statistics__timed__downloads":"0","statistics__forever__storage":"0","statistics__forever__bandwidth":"0","statistics__forever__downloads":"0","limits__server__forever__storage":null,"limits__server__timed__bandwidth":null,"limits__server__timed__downloads":null,"limits__server__timed-expire":null,"limits__server__public-filecount":null,"limits__server__public-filesize":null,"limits__users__filesize":null,"limits__users__filecount":null,"limits__users__forever__storage":null,"limits__users__timed__bandwidth":null,"limits__users__timed__downloads":null}

52 52

致命错误:C:\Program Files\Apache24\htdocs\development\Andromeda\server\classes\database.class.inc.php:28 堆栈跟踪中的未捕获异常 'PDOException' 和消息 'SQLSTATE[HY093]: Invalid parameter number: parameter was not defined':28 堆栈跟踪:#0 C:\Program Files\Apache24\htdocs\development\Andromeda\server\classes\database.class.inc.php(28): PDOStatement->execute(Array) #1 C:\Program Files\Apache24\htdocs\development\Andromeda\server\classes\server.class.inc.php(117): 数据库->query('UPDATE objects_...', 数组, false) #2 C:\Program Files\Apache24\htdocs\development\Andromeda\index.php(71): Server->Save() #3 C:\Program Files\Apache24\htdocs\development\Andromeda\index.php(32): Andromeda->运行() #4 {main} thrown in C:\Program Files\Apache24\htdocs\development\Andromeda\server\classes\database.class.inc.php on line 28

我似乎已经缩小了它的范围 - 仅限 PDO returns 如果其中一个键包含像 :test__variable-hyphen 这样的连字符,则会出错。为什么不允许?

许多特殊字符(例如 +、-、逗号...)不是合法的列名,除非您将列名括在 bactics 中:test__variable-hyphen.

否则,它看起来太像减法了。