diff --git a/functions.inc.php b/functions.inc.php index 102bc43b..fee1511a 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -1562,6 +1562,33 @@ function db_get_boolean($bool) { return 1; } return 0; + } else { + die('Unknown value in $CONF[database_type]'); + } +} + +/** + * Converts a boolean value from the database internal format to integer (0 or 1) + * Currently only PostgreSQL and MySQL are supported. + * @param string $bool (REQUIRED) + * @return int + */ +function db_boolean_to_int($bool) { + global $CONF; + + if($CONF['database_type']=='pgsql') { + // return either true or false (unquoted strings) + if($bool == 't') { + return 1; + } + return 0; + } elseif($CONF['database_type'] == 'mysql' || $CONF['database_type'] == 'mysqli') { + if($bool) { + return 1; + } + return 0; + } else { + die('Unknown value in $CONF[database_type]'); } }