Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
15 changes: 13 additions & 2 deletions webdata/scripts/table-build.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@
$p = pathinfo($m);
$o = new $p['filename'];
if($o instanceof Pix_Table) {
$o->dropTable();
try {
$o->dropTable();
} catch (Pix_Table_Exception $e) {
echo 'Unable to drop table "'.$p['filename'].'". ';
if (preg_match('/^Table: \w+SQL Error: \(1051\)Unknown table/',
$e->getMessage())) {
echo 'Table missing. Ignored.'."\n";
} else {
echo "\n";
die($e->getMessage());
}
}
$o->createTable();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class Pix_Table_Db_Adapter_MysqlCommon extends Pix_Table_Db_Adapter_SQL
public function createTable($table)
{
$sql = "CREATE TABLE " . $this->column_quote($table->getTableName());
$types = array('bigint', 'tinyint', 'int', 'varchar', 'char', 'text', 'float', 'double', 'binary');
$types = array('bigint', 'tinyint', 'int', 'varchar', 'char', 'text', 'longtext', 'float', 'double', 'binary');

foreach ($table->_columns as $name => $column) {
$s = $this->column_quote($name) . ' ';
Expand Down Expand Up @@ -73,7 +73,7 @@ public function createTable($table)
$column_sql[] = $s;
}

$sql .= " (\n" . implode(", \n", $column_sql) . ") ENGINE = InnoDB\n";
$sql .= " (\n" . implode(", \n", $column_sql) . ") ENGINE = InnoDB DEFAULT CHARSET=utf8mb4\n";

return $this->query($sql, $table);
}
Expand Down