functions.inc.php: add a db_get_boolean($bool) function to handle the 0/1/False/True stuff for MySQL&PostgreSQL

git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@73 a1433add-5e2c-0410-b055-b7f2511e0802
postfixadmin-2.3
David Goodwin 17 years ago
parent 2d3058ed9c
commit 5c372ead52

@ -1256,7 +1256,32 @@ function db_connect ()
}
}
/**
* Returns the appropriate boolean value for the database.
* Currently only PostgreSQL and MySQL are supported.
* @param boolean $bool (REQUIRED)
* @return String or int as appropriate.
*/
function db_get_boolean($bool) {
if(!is_boolean($bool)) {
die("Invalid usage of 'db_get_boolean($bool)'");
}
global $CONF;
if($CONF['database_type']=='pgsql') {
// return either true or false (unquoted strings)
if($bool) {
return 'true';
}
return 'false';
}
elseif($CONF['database_type'] == 'mysql') {
if($bool) {
return 1;
}
return 0;
}
}
//
// db_query

Loading…
Cancel
Save