// remove the index on hotpot_questions.name
$table = 'hotpot_questions';
$field = 'name';
- if (strtolower($CFG->dbtype)=='postgres7') {
+ if (strtolower($CFG->dbfamily)=='postgres') {
$index = "{$CFG->prefix}{$table}_{$field}_idx";
} else {
$index = "{$table}_{$field}_idx";
// remove the index on hotpot_strings.string
$table = 'hotpot_strings';
$field = 'string';
- if (strtolower($CFG->dbtype)=='postgres7') {
+ if (strtolower($CFG->dbfamily)=='postgres') {
$index = "{$CFG->prefix}{$table}_{$field}_idx";
} else {
$index = "{$table}_{$field}_idx";
global $CFG;
$ok = true;
- if (strtolower($CFG->dbtype)=='postgres7') {
+ if (strtolower($CFG->dbfamily)=='postgres') {
// ensure setting of default values on certain fields
// this was originally done in postgres7.php, but was found to be incompatible with PG7 :-(
$table="hotpot";
// make sure type of 'name' is a text field (not varchar 255)
$ok = $ok && hotpot_db_update_field_type('hotpot_questions', 'name', 'name', 'TEXT', '', '', 'NOT NULL', '');
- if (strtolower($CFG->dbtype)=='mysql') {
+ if (strtolower($CFG->dbfamily)=='mysql') {
// set default values on certain VARCHAR(255) fields
$fields = array(
function hotpot_update_to_v2_1_8() {
global $CFG;
$ok = true;
- if (strtolower($CFG->dbtype)=='postgres7') {
+ if (strtolower($CFG->dbfamily)=='postgres') {
// add, delete and rename certain fields and indexes
// that were not correctly setup by postgres7.sql
global $CFG;
$ok = true;
- if (strtolower($CFG->dbtype)=='postgres7') {
+ if (strtolower($CFG->dbfamily)=='postgres') {
// add, delete and rename certain fields and indexes
// that were not correctly setup by postgres7.sql
// hotpot_questions: change type of "name" field to "text"
$ok = $ok && hotpot_db_update_field_type('hotpot_questions', 'name', 'name', 'TEXT', '', '', 'NOT NULL', '');
// hotpot_questions: nullify empty and non-numeric (shouldn't be any) values in "text" field
- switch (strtolower($CFG->dbtype)) {
+ switch (strtolower($CFG->dbfamily)) {
case 'mysql' :
$NOT_REGEXP = 'NOT REGEXP';
break;
- case 'postgres7' :
+ case 'postgres' :
$NOT_REGEXP = '!~';
break;
default:
// do nothing
} else {
$ok = $ok && hotpot_create_table($table);
- switch (strtolower($CFG->dbtype)) {
+ switch (strtolower($CFG->dbfamily)) {
case 'mysql' :
- case 'postgres7' :
+ case 'postgres' :
$sql = "
INSERT INTO {$CFG->prefix}$table (attempt, details)
SELECT a.id AS attempt, a.details AS details
// save and switch off SQL message echo
$debug = $db->debug;
$db->debug = $feedback;
- switch (strtolower($CFG->dbtype)) {
+ switch (strtolower($CFG->dbfamily)) {
case 'mysql' :
$rs = $db->Execute("SHOW INDEX FROM `$table`");
if ($rs && $rs->RecordCount()>0) {
}
}
break;
- case 'postgres7' :
+ case 'postgres' :
$rs = $db->Execute("SELECT relname FROM pg_class WHERE relname = '$index' AND relkind='i'");
if ($rs && $rs->RecordCount()>0) {
$exists = true;
$ok = true;
// check index exists
if (hotpot_db_index_exists($table, $index)) {
- switch (strtolower($CFG->dbtype)) {
+ switch (strtolower($CFG->dbfamily)) {
case 'mysql' :
$sql = "ALTER TABLE `$table` DROP INDEX `$index`";
break;
- case 'postgres7' :
+ case 'postgres' :
$sql = "DROP INDEX $index";
break;
default: // unknown database type
function hotpot_db_add_index($table, $field, $length='') {
global $CFG, $db;
- if (strtolower($CFG->dbtype)=='postgres7') {
+ if (strtolower($CFG->dbfamily)=='postgres') {
$index = "{$CFG->prefix}{$table}_{$field}_idx";
} else {
// mysql (and others)
// delete $index if it already exists
$ok = hotpot_db_delete_index($table, $index);
- switch (strtolower($CFG->dbtype)) {
+ switch (strtolower($CFG->dbfamily)) {
case 'mysql' :
$ok = $ok && $db->Execute("ALTER TABLE `$table` ADD INDEX `$index` (`$field`)");
break;
- case 'postgres7' :
+ case 'postgres' :
$ok = $ok && $db->Execute("CREATE INDEX $index ON $table (\"$field\")");
break;
default: // unknown database type
// expand table name
$table = "{$CFG->prefix}$table";
// set $sql
- switch (strtolower($CFG->dbtype)) {
+ switch (strtolower($CFG->dbfamily)) {
case 'mysql' :
if (empty($field)) {
$sql = "SHOW TABLES LIKE '$table'";
$sql = "SHOW COLUMNS FROM `$table` LIKE '$field'";
}
break;
- case 'postgres7' :
+ case 'postgres' :
if (empty($field)) {
$sql = "SELECT relname FROM pg_class WHERE relname = '$table' AND relkind='r'";
} else {
if (empty($fieldnames)) {
$ok = false;
} else {
- switch (strtolower($CFG->dbtype)) {
+ switch (strtolower($CFG->dbfamily)) {
case 'mysql':
$ok = execute_sql("INSERT INTO `$table` ($fieldnames) SELECT $fieldnames FROM `$oldtable` WHERE 1");
break;
- case 'postgres7':
+ case 'postgres':
$ok = execute_sql("INSERT INTO $table ($fieldnames) SELECT $fieldnames FROM $oldtable");
break;
default:
function hotpot_db_set_table_comment($table, $comment, $feedback=true) {
global $CFG;
$ok = true;
- switch (strtolower($CFG->dbtype)) {
+ switch (strtolower($CFG->dbfamily)) {
case 'mysql' :
$ok = execute_sql("ALTER TABLE {$CFG->prefix}$table COMMENT='$comment'");
break;
- case 'postgres7' :
+ case 'postgres' :
$ok = execute_sql("COMMENT ON TABLE {$CFG->prefix}$table IS '$comment'");
break;
}
// set full table name
$table = "{$CFG->prefix}$table";
// update the field in the database
- switch (strtolower($CFG->dbtype)) {
+ switch (strtolower($CFG->dbfamily)) {
case 'mysql':
// optimize integer types
switch (strtoupper($type)) {
}
$ok = $ok && execute_sql("ALTER TABLE `$table` $action `$field` $fieldtype");
break;
- case 'postgres7':
+ case 'postgres':
// get db version
// N.B. $db->ServerInfo() usually returns blank
// (except lib/adodb/drivers/adodb-postgre64-inc.php)
execute_sql('VACUUM FULL '.$table);
}
break;
- } // end switch $CGF->dbtype
+ } // end switch $CGF->dbfamily
return $ok;
}
function hotpot_db_update_record($table, $record, $forcenull=false) {
$grade = "ROUND(SUM(score)/COUNT(id) * $weighting, $precision) AS grade";
break;
case HOTPOT_GRADEMETHOD_FIRST:
- if ($CFG->dbtype=='postgres7') {
+ if ($CFG->dbfamily=='postgres') {
$grade = "(CASE WHEN (score IS NULL)
THEN ''
ELSE TRIM(ROUND(score * $weighting, $precision))
$grade = "MIN($grade) AS grade";
break;
case HOTPOT_GRADEMETHOD_LAST:
- if ($CFG->dbtype=='postgres7') {
+ if ($CFG->dbfamily=='postgres') {
$grade = "(CASE WHEN (score IS NULL)
THEN ''
ELSE TRIM(ROUND(score * $weighting, $precision))
function hotpot_add_attempt($hotpotid) {
global $db, $CFG, $USER;
$time = time();
- switch (strtolower($CFG->dbtype)) {
+ switch (strtolower($CFG->dbfamily)) {
case 'mysql':
$timefinish = "IF(a.timefinish IS NULL, '$time', a.timefinish)";
$clickreportid = "IF(a.clickreportid IS NULL, a.id, a.clickreportid)";
break;
- case 'postgres7':
+ case 'postgres':
$timefinish = "WHEN(a.timefinish IS NULL) THEN '$time' ELSE a.timefinish";
$clickreportid = "WHEN(a.clickreportid IS NULL) THEN a.id ELSE a.clickreportid";
break;