i trying to run this code by 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
what should i do ?
this: 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 >= ?.?
and pass 2 parameters to the pdo statement. You would then have to pass x >= ?
and then bindValue(5.1);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.