forked from GithubBackups/tinyib
Create reports table
This commit is contained in:
parent
b985ded3ee
commit
b225fc00a1
@ -27,6 +27,11 @@ if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . TINYIB_DBBANS . "'")) == 0
|
|||||||
mysql_query($bans_sql);
|
mysql_query($bans_sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the reports table if it does not exist
|
||||||
|
if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . TINYIB_DBREPORTS . "'")) == 0) {
|
||||||
|
mysql_query($reports_sql);
|
||||||
|
}
|
||||||
|
|
||||||
if (mysql_num_rows(mysql_query("SHOW COLUMNS FROM `" . TINYIB_DBPOSTS . "` LIKE 'stickied'")) == 0) {
|
if (mysql_num_rows(mysql_query("SHOW COLUMNS FROM `" . TINYIB_DBPOSTS . "` LIKE 'stickied'")) == 0) {
|
||||||
mysql_query("ALTER TABLE `" . TINYIB_DBPOSTS . "` ADD COLUMN stickied TINYINT(1) NOT NULL DEFAULT '0'");
|
mysql_query("ALTER TABLE `" . TINYIB_DBPOSTS . "` ADD COLUMN stickied TINYINT(1) NOT NULL DEFAULT '0'");
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,11 @@ if (mysqli_num_rows(mysqli_query($link, "SHOW TABLES LIKE '" . TINYIB_DBBANS . "
|
|||||||
mysqli_query($link, $bans_sql);
|
mysqli_query($link, $bans_sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the reports table if it does not exist
|
||||||
|
if (mysqli_num_rows(mysqli_query($link, "SHOW TABLES LIKE '" . TINYIB_DBREPORTS . "'")) == 0) {
|
||||||
|
mysqli_query($link, $reports_sql);
|
||||||
|
}
|
||||||
|
|
||||||
if (mysqli_num_rows(mysqli_query($link, "SHOW COLUMNS FROM `" . TINYIB_DBPOSTS . "` LIKE 'stickied'")) == 0) {
|
if (mysqli_num_rows(mysqli_query($link, "SHOW COLUMNS FROM `" . TINYIB_DBPOSTS . "` LIKE 'stickied'")) == 0) {
|
||||||
mysqli_query($link, "ALTER TABLE `" . TINYIB_DBPOSTS . "` ADD COLUMN stickied TINYINT(1) NOT NULL DEFAULT '0'");
|
mysqli_query($link, "ALTER TABLE `" . TINYIB_DBPOSTS . "` ADD COLUMN stickied TINYINT(1) NOT NULL DEFAULT '0'");
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ if (TINYIB_DBDRIVER === 'pgsql') {
|
|||||||
$dbh->query("SHOW TABLES LIKE " . $dbh->quote(TINYIB_DBPOSTS));
|
$dbh->query("SHOW TABLES LIKE " . $dbh->quote(TINYIB_DBPOSTS));
|
||||||
$posts_exists = $dbh->query("SELECT FOUND_ROWS()")->fetchColumn() != 0;
|
$posts_exists = $dbh->query("SELECT FOUND_ROWS()")->fetchColumn() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$posts_exists) {
|
if (!$posts_exists) {
|
||||||
$dbh->exec($posts_sql);
|
$dbh->exec($posts_sql);
|
||||||
}
|
}
|
||||||
@ -49,11 +48,22 @@ if (TINYIB_DBDRIVER === 'pgsql') {
|
|||||||
$dbh->query("SHOW TABLES LIKE " . $dbh->quote(TINYIB_DBBANS));
|
$dbh->query("SHOW TABLES LIKE " . $dbh->quote(TINYIB_DBBANS));
|
||||||
$bans_exists = $dbh->query("SELECT FOUND_ROWS()")->fetchColumn() != 0;
|
$bans_exists = $dbh->query("SELECT FOUND_ROWS()")->fetchColumn() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$bans_exists) {
|
if (!$bans_exists) {
|
||||||
$dbh->exec($bans_sql);
|
$dbh->exec($bans_sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the reports table if it does not exist
|
||||||
|
if (TINYIB_DBDRIVER === 'pgsql') {
|
||||||
|
$query = "SELECT COUNT(*) FROM pg_catalog.pg_tables WHERE tablename LIKE " . $dbh->quote(TINYIB_DBREPORTS);
|
||||||
|
$reports_exists = $dbh->query($query)->fetchColumn() != 0;
|
||||||
|
} else {
|
||||||
|
$dbh->query("SHOW TABLES LIKE " . $dbh->quote(TINYIB_DBREPORTS));
|
||||||
|
$reports_exists = $dbh->query("SELECT FOUND_ROWS()")->fetchColumn() != 0;
|
||||||
|
}
|
||||||
|
if (!$reports_exists) {
|
||||||
|
$dbh->exec($reports_sql);
|
||||||
|
}
|
||||||
|
|
||||||
if (TINYIB_DBDRIVER === 'pgsql') {
|
if (TINYIB_DBDRIVER === 'pgsql') {
|
||||||
$query = "SELECT column_name FROM information_schema.columns WHERE table_name='" . TINYIB_DBPOSTS . "' and column_name='moderated'";
|
$query = "SELECT column_name FROM information_schema.columns WHERE table_name='" . TINYIB_DBPOSTS . "' and column_name='moderated'";
|
||||||
$moderated_exists = $dbh->query($query)->fetchColumn() != 0;
|
$moderated_exists = $dbh->query($query)->fetchColumn() != 0;
|
||||||
|
@ -56,6 +56,16 @@ if (!$result->fetchArray()) {
|
|||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the reports table if it does not exist
|
||||||
|
$result = $db->query("SELECT name FROM sqlite_master WHERE type='table' AND name='" . TINYIB_DBREPORTS . "'");
|
||||||
|
if (!$result->fetchArray()) {
|
||||||
|
$db->exec("CREATE TABLE " . TINYIB_DBREPORTS . " (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
ip TEXT NOT NULL,
|
||||||
|
post INTEGER NOT NULL
|
||||||
|
)");
|
||||||
|
}
|
||||||
|
|
||||||
// Add moderated column if it isn't present
|
// Add moderated column if it isn't present
|
||||||
@$db->exec("ALTER TABLE " . TINYIB_DBPOSTS . " ADD COLUMN moderated INTEGER NOT NULL DEFAULT '0'");
|
@$db->exec("ALTER TABLE " . TINYIB_DBPOSTS . " ADD COLUMN moderated INTEGER NOT NULL DEFAULT '0'");
|
||||||
|
|
||||||
|
@ -55,6 +55,16 @@ if (sqlite_num_rows($result) == 0) {
|
|||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the reports table if it does not exist
|
||||||
|
$result = sqlite_query($db, "SELECT name FROM sqlite_master WHERE type='table' AND name='" . TINYIB_DBREPORTS . "'");
|
||||||
|
if (sqlite_num_rows($result) == 0) {
|
||||||
|
sqlite_query($db, "CREATE TABLE " . TINYIB_DBREPORTS . " (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
ip TEXT NOT NULL,
|
||||||
|
post INTEGER NOT NULL
|
||||||
|
)");
|
||||||
|
}
|
||||||
|
|
||||||
// Add moderated column if it isn't present
|
// Add moderated column if it isn't present
|
||||||
sqlite_query($db, "ALTER TABLE " . TINYIB_DBPOSTS . " ADD COLUMN moderated INTEGER NOT NULL DEFAULT '0'");
|
sqlite_query($db, "ALTER TABLE " . TINYIB_DBPOSTS . " ADD COLUMN moderated INTEGER NOT NULL DEFAULT '0'");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user