3

我可以在参数
示例中使用几行吗

SELECT id, city_id FROM an_objects WHERE city_id IN (:arrCity)

(:arrCity) (1,2,3,4,5,6)

但现在我已经这样做了

SELECT id, city_id FROM an_objects WHERE city_id IN (:1p, :2p, :3p, ...... :100p)

而且非常糟糕

4

2 回答 2

3
<?php

private function PDOBindArray(&$poStatement, &$paArray){ 
    foreach ($paArray as $k=>$v) {
        @$poStatement->bindValue($k, $v[0], $v[1]);
    }      
}

// the array structure should now look something like this

$inputArray = array(
    ':arrcity' => array($email, PDO::PARAM_STR), 
    ':another_variable' => array($pass, PDO::PARAM_INT)
);
?>
于 2012-12-19T22:27:29.140 回答
0

在这种情况下如何成为查询?

WHERE city_id IN (:1p, :2p, :3p, ...... :100p)

在查询100个参数
这个方法中,例如我们只有5个参数

private function PDOBindArray(&$poStatement, &$paArray){ 
    foreach ($paArray as $k=>$v) {
        @$poStatement->bindValue($k, $v[0], $v[1]);
    }      
}
于 2012-12-20T06:27:23.553 回答