mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-19 19:22:14 +02:00
functions.inc.php:
- new function db_boolean_to_int() to convert boolean values from the database to integer (0 or 1) - db_get_boolean(): error out on unknown $CONF[database_type] git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1208 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
parent
bf2d5e0f4b
commit
da21a4cae2
@ -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]');
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user