简体   繁体   English

违反基数:1241操作数应包含1列PDO

[英]Cardinality violation: 1241 Operand should contain 1 column(s) PDO

i trying to run this code by pdo 我试图通过pdo运行此代码

db::query("SELECT v.id, v.rel_x, v.rel_y FROM p_villages v WHERE v.field_maps_id=3
            AND ISNULL(v.player_id) AND (v.rel_x >= ?,?,?,? AND v.rel_x <= ?,?,?,?)
            AND (v.rel_y >= ?,?,?,? AND v.rel_y <= ?,?,?,?)
            AND v.rand_num > 0 ORDER BY v.rand_num LIMIT 1",array(1,2,3,3,1,2,3,3,1,2,3,3,1,2,3,3));

but i found this error 但是我发现了这个错误

Warning: PDOStatement::execute(): SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s) \

so, i need the output query like SELECT v.id, v.rel_x, v.rel_y FROM p_villages v WHERE v.field_maps_id=3 AND ISNULL(v.player_id) AND (v.rel_x >= 1,2,3,4 AND v.rel_x <= 1,2,3,4) AND (v.rel_y >= 1,2,3,4 AND v.rel_y <= 1,2,3,4) AND v.rand_num > 0 ORDER BY v.rand_num LIMIT 1 and in the parameters i want to pass each parameter of those parameters which here is 16 因此,我需要类似SELECT v.id, v.rel_x, v.rel_y FROM p_villages v WHERE v.field_maps_id=3 AND ISNULL(v.player_id) AND (v.rel_x >= 1,2,3,4 AND v.rel_x <= 1,2,3,4) AND (v.rel_y >= 1,2,3,4 AND v.rel_y <= 1,2,3,4) AND v.rand_num > 0 ORDER BY v.rand_num LIMIT 1的输出查询SELECT v.id, v.rel_x, v.rel_y FROM p_villages v WHERE v.field_maps_id=3 AND ISNULL(v.player_id) AND (v.rel_x >= 1,2,3,4 AND v.rel_x <= 1,2,3,4) AND (v.rel_y >= 1,2,3,4 AND v.rel_y <= 1,2,3,4) AND v.rand_num > 0 ORDER BY v.rand_num LIMIT 1 ,在参数中,我想传递这些参数中的每个参数,这里是16

what should i do ? 我该怎么办 ?

this: v.rel_y <= ?,?,?,? v.rel_y <= ?,?,?,?

looks weird. 看起来很奇怪。

Bound parameters have to be self contained, you cannot build the right or left part of a comparison by more than one. 绑定参数必须是自包含的,您不能将比较的左右部分相加一个以上。

ie, if you mean to say x >= 5.1 , you cannot put x >= ?.? 即,如果您要说x >= 5.1 ,则不能将x >= ?.? and pass 2 parameters to the pdo statement. 并将2个参数传递给pdo语句。 You would then have to pass x >= ? 然后,您必须通过x >= ? and then bindValue(5.1); 然后bindValue(5.1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM