有一个问题,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;
}
UPDATE objects_servers SET id
= :id
,info__enabled
= :info__enabled
,info__version
= :info__version
,info__title
= {{ 1}},:info__title
= info__color
,:info__color
= info__contact
,:info__contact
= info__chunksize
,:info__chunksize
= {{1} },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
,{{ 1}} = 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
,{{1} } = :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
= {{ 1}},:features__server__softlimit
= features__server__publiclimit
,:features__server__publiclimit
= features__server__hourly-statistics
,:features__server__hourly-statistics
= features__server__actionlog
,:features__server__actionlog
= {{1} },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
+ = {{1} },:features__server__multiple-accounts
+ = statistics__timed__#start
,:statistics__timed__#start
+ = statistics__timed__storage
,:statistics__timed__storage
+ = statistics__timed__bandwidth
,:statistics__timed__bandwidth
+ = {{ 1}},statistics__timed__downloads
= :statistics__timed__downloads
,statistics__forever__storage
= :statistics__forever__storage
,statistics__forever__bandwidth
= :statistics__forever__bandwidth
,statistics__forever__downloads
= {{1} },: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
WHERE :limits__users__filesize
='DjvMb938gkH867d3';
{ “ID”: “DjvMb938gkH867d3”, “info__enabled”: “1”, “info__version”: “0.0.1”, “info__title”: “发展”, “info__color”: “#007127”, “info__contact” : “yeeeup”, “info__chunksize”: “2097152”, “info__downloadwait”: “10”, “info__crypto__ciphers”: “蛇:CTR”, “info__crypto__salt长度”: “512”, “info__crypto__pbkdf2算法”: “SHA512” “info__crypto__pbkdf2迭代”: “5000”, “info__crypto__chunk大小”: “1048576”, “info__email__hostname”: “好玩”, “info__email__smtp-auth的”: “1”, “info__email__auth密码”: “没了”,” info__email__auth-用户名 “:” blah1" , “info__email__from地址”: “blah2”, “info__email__from名”: “人”, “info__email__port”: “587”, “info__email__smtp安全”: “TLS”,“info__email__bcc-地址 “:” blah3" , “features__users__download-页”: “1”, “features__users__file-加密”: “1”, “features__users__admin”: “0”, “features__server__email验证”: “0”, “features__server__softlimit”:” 1" , “features__server__publiclimit”: “0”, “features__server__hourly统计”: “1”, “features__server__actionlog”: “1”,“features__server__限制的警告 “:” 1" , “features__server__sequential-contentfill”: “0”, “features__server__outgoing电子邮件”: “0”, “features__server__multiple账户”: “1”, “statistics__timed __#开始”:空, “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”:空“limits__server__timed__bandwidth”:空, “limits__server__timed__downloads”:空, “limits__server__timed-过期”:空, “limits__server__public-filecount”:空, “limits__server__public-文件大小”:空, “limits__users__filesize”:空, “limits__users__filecount”:空” limits__users__forever__storage “:NULL,” limits__users__timed__bandwidth “:NULL,” limits__users__timed__downloads“:空}
52 52
致命错误:未捕获异常'PDOException',消息'SQLSTATE [HY093]:参数号无效:参数未在C:\ Program Files \ Apache24 \ htdocs \ development \ Andromeda \ server \ classes \ database.class中定义.inc.php: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):Database-> query('UPDATE objects _...',Array,false)#2C :\ Program Files \ Apache24 \ htdocs \ development \ Andromeda \ index.php(71):Server-> Save()#3 C:\ Program Files \ Apache24 \ htdocs \ development \ Andromeda \ index.php(32): Andromeda-> Run()#4 {main}在第28行的C:\ Program Files \ Apache24 \ htdocs \ development \ Andromeda \ server \ classes \ database.class.inc.php中抛出
答案 0 :(得分:0)
我似乎缩小了它 - 如果其中一个键包含一个连字符,则PDO只返回错误:test__variable-hyphen。为什么不允许这样做?
答案 1 :(得分:0)
许多特殊字符(例如+, - ,逗号,...)不是合法的列名,除非您将列名括在bactics中:test__variable-hyphen
。
否则,它看起来太像减法了。