21,886
社区成员
发帖
与我相关
我的任务
分享
$rows = Array
(
'0' => Array
(
'id' => 9,
'picid' => 8
),
'1' => Array
(
'id' => 10,
'picid' => 12
),
'2' => Array
(
'id' => 11,
'picid' => 16
),
'3' => Array
(
'id' => 12,
'picid' => 20
),
'4' => Array
(
'id' => 13,
'picid' => 24
),
'5' => Array
(
'id' => 14,
'picid' => 28
),
'6' => Array
(
'id' => 15,
'picid' => 32
),
'7' => Array
(
'id' => 16,
'picid' => 36
),
'8' => Array
(
'id' => 17,
'picid' => 40
),
'9' => Array
(
'id' => 18,
'picid' => 44
),
'10' => Array
(
'id' => 19,
'picid' => 48
)
);
$count = 0;
$sql = "SELECT * FROM `pictb` WHERE";
foreach($rows as $row){
$filehash = $db->getOne("SELECT filehash FROM `pictb` WHERE id=".$row["picid"]);
if($count<1){
$sql .=" filehash='".$filehash["filehash"]."'";
}else{
$sql .=" OR filehash='".$filehash["filehash"]."'";
}
$count++;
}
foreach($rows as $row){
$filehash = $db->getOne("SELECT filehash FROM `pictb` WHERE id=".$row["picid"]);
$sql ="SELECT * FROM `ews_attachment` WHERE filehash='".$filehash["filehash"]."'";
$arr[] = $db->getRows($sql);
}
$filehash = $db->getOne("SELECT filehash FROM `pictb` WHERE id=".$row["picid"]);
$sql ="SELECT * FROM `ews_attachment` WHERE filehash='".$filehash["filehash"]."'";
$picid=array();
foreach($rows as $k=>$v){
$picid[] = $v['picid'];
}
$picid = "'".join("','",$picid)."'";
$sql="SELECT p.filehash,a.* FROM `pictb` p
left join `ews_attachment` a on a.filehash=p.filehash
WHERE p.id in($picid)";
$query=mysql_query($sql);
$data=array();
while($row = mysql_fetch_array($query)){
$data[]=$row;
}
print_r($data);