首先,也许我做错了所以要善待;)
我必须通过循环数组生成我的SQL请求:
$sql = "SELECT data_mt_poids.Fap87, Type, Part, Info, Fap87_libcourt
FROM data_mt_poids
INNER JOIN lib_fap87 ON data_mt_poids.Fap87 = lib_fap87.Fap87
WHERE ";
$i = 1;
foreach($liste_territoire as $territoire)
{
foreach($fap_array as $fap)
{
$sql .= "data_mt_poids.ZEFAP = ? OR ";
}
}
$sql = substr($sql, 0, - 3);
$results = null;
try
{
$conn = Db::getInstance();
$stmt = $conn->prepare($sql);
$i = 1;
foreach($liste_territoire as $territoire)
{
foreach($fap_array as $fap)
{
$requested_zefap = $territoire.'-'.$fap;
$stmt->bindParam($i, $requested_zefap);
++$i;
}
}
$stmt->execute();
$results = $stmt->fetchAll(PDO::FETCH_OBJ);
}
catch(PDOException $e)
{
die("Error ".$e->getCode()." : ".$e->getMessage());
}
有4个territoire和2个F.A.P。
我已经记录了SQL请求,没关系,实际上对我来说一切似乎都很好:/
这只返回最后一个可能的结果(最后一个$ territoire- $ fap couple)
这只发生在我使用准备好的查询时:/
这是一个debugDumpParams():
SQL: [361] SELECT data_mt_poids.Fap87, Type, Part, Info, Fap87_libcourt FROM data_mt_poids INNER JOIN lib_fap87 ON data_mt_poids.Fap87 = lib_fap87.Fap87 WHERE data_mt_poids.ZEFAP = ? OR data_mt_poids.ZEFAP = ? OR data_mt_poids.ZEFAP = ? OR data_mt_poids.ZEFAP = ? OR data_mt_poids.ZEFAP = ? OR data_mt_poids.ZEFAP = ? OR data_mt_poids.ZEFAP = ? OR data_mt_poids.ZEFAP = ?
Params: 8
Key: Position #0:
paramno=0
name=[0] ""
is_param=1
param_type=2
Key: Position #1:
paramno=1
name=[0] ""
is_param=1
param_type=2
Key: Position #2:
paramno=2
name=[0] ""
is_param=1
param_type=2
Key: Position #3:
paramno=3
name=[0] ""
is_param=1
param_type=2
Key: Position #4:
paramno=4
name=[0] ""
is_param=1
param_type=2
Key: Position #5:
paramno=5
name=[0] ""
is_param=1
param_type=2
Key: Position #6:
paramno=6
name=[0] ""
is_param=1
param_type=2
Key: Position #7:
paramno=7
name=[0] ""
is_param=1
param_type=2
提前感谢您的帮助;)