Skip to content

Commit

Permalink
改進 news-raw-tables.php 產生表格的方法
Browse files Browse the repository at this point in the history
原有方法直接用 SQL 語句產生表格,表格的結構不能隨 Pix_Table 實現而改變,比較不靈活。

改用 Ronny 在[這裏](https://github.com/ronnywang/newsdiff/issues/18#issuecomment-59484616)提及的方法產生 news_raw 表格。
  • Loading branch information
yookoala committed Jan 7, 2015
1 parent eec225c commit fff9367
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions webdata/scripts/news-raw-tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
* to create 12 tables for NewsRaw
*/
$theTime = mktime();
$str = "CREATE TABLE IF NOT EXISTS `news_raw_%s` (
`news_id` int(11) NOT NULL,
`time` int(11) NOT NULL,
`raw` text NOT NULL,
PRIMARY KEY (`news_id`,`time`)
) ENGINE=InnoDB;";
$str = 'CREATE TABLE IF NOT EXISTS `news_raw_%s` LIKE news_raw';
$db = NewsRaw::getDb();
for ($i = 0; $i < 12; $i++) {
$db->query(sprintf($str, date('Ym', $theTime)));
$theTime = strtotime('+1 month', $theTime);
}
}

0 comments on commit fff9367

Please sign in to comment.