-1
我2個組合查詢:$stmt1
和$stmt2
到第三陣列($results
)合併所有結果,並利用它們來輸出1 RSS提要...飼料的作品,但它是從上市的所有$stmt1
由結果第一event_start
和然後,從$stmt2
通過event_start
結果...我想既有 '組合拳' 的結果event_start
數組排序問題
<?
header("Content-Type: application/rss+xml; charset=ISO-8859-1");
$rssfeed = "<?xml version='1.0' encoding='ISO-8859-1'?>";
$rssfeed .= "<rss version='2.0'>";
$rssfeed .= "<channel>";
$rssfeed .= "<title></title>";
$rssfeed .= "<link></link>";
$rssfeed .= "<description></description>";
$rssfeed .= "<language>en-us</language>";
$db1 = new PDO('mysql:host='.$db_host1.';dbname='.$db_name1,$db_username1,$db_pass1);
$db2 = new PDO('mysql:host='.$db_host2.';dbname='.$db_name2,$db_username2,$db_pass2);
$db1->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING);
$db2->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING);
$stmt1 = $db1->query("SELECT event_start, title, s_description FROM special_events WHERE event_start >= NOW() ORDER BY event_start ASC");
$stmt2 = $db2->query("SELECT event_start, title, s_description FROM special_events WHERE event_start >= NOW() ORDER BY event_start ASC");
$results = array_merge($stmt1->fetchAll(PDO::FETCH_ASSOC), $stmt2->fetchAll(PDO::FETCH_ASSOC));
$events = array();
foreach ($results as $key => $row) {
$rssfeed .= "<item>";
$date[$key] = $row['event_start'];
$rssfeed .= "<title>".htmlentities($row['title'])."</title>";
$rssfeed .= "<description>".htmlentities($row['s_description'])."</description>";
$rssfeed .= "<link>http://link.com</link>";
$rssfeed .= "<pubdate>".$row['event_start']."</pubdate>";
$rssfeed .= "</item>";
}
$rssfeed .= '</channel>';
$rssfeed .= '</rss>';
array_multisort($date, SORT_ASC, $results); //not working
echo ($rssfeed);
?>