我有我从下面的PDO得到一个数组:PDO阵列从MySQL查询到插入查询
$sqlQry = "SELECT Devices.dID FROM Friends LEFT OUTER JOIN Devices ON Friends.fID = Devices.dUID WHERE Devices.dID IS NOT NULL GROUP BY Devices.dID";
$db = getConnection();
$sth = $db->prepare($sqlQry);
$sth->execute();
print("Fetch all of the remaining rows in the result set:\n");
$result = $sth->fetchAll();
print_r($result);
数组返回:
Array ([0] => Array ([dID] => 2[0] => 2) [1] => Array ([dID] => 3 [0] => 3))
对于DID值中的每一个I需要运行插入查询,该插入查询采用dID并将其插入到具有外部值的同一个数据库中的表中。
$sqlIns = "INSERT INTO messages (dID, message, status") VALUES (?,?,?);
消息和状态将在可变
举行任何一个可以帮助我这一个?
为什么不在一个查询中完成这一切? – RedFilter 2012-07-17 13:04:18