From ee35b8a0808da6e3edd86c1f82a40eaaefaf6b85 Mon Sep 17 00:00:00 2001 From: nikrou Date: Mon, 24 May 2010 20:12:35 +0000 Subject: Fix bug 1695 : incorrect boolean to string conversion for SQLite and PostgreSQL database engines git-svn-id: http://piwigo.org/svn/trunk@6339 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/dblayer/functions_pdo-sqlite.inc.php | 6 +++--- include/dblayer/functions_pgsql.inc.php | 6 +++--- include/dblayer/functions_sqlite.inc.php | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/dblayer/functions_pdo-sqlite.inc.php b/include/dblayer/functions_pdo-sqlite.inc.php index a4c3881f0..a1f0a7833 100644 --- a/include/dblayer/functions_pdo-sqlite.inc.php +++ b/include/dblayer/functions_pdo-sqlite.inc.php @@ -467,13 +467,13 @@ function get_boolean( $string ) */ function boolean_to_string($var) { - if (!empty($var) && ($var == 'true')) + if (is_bool($var)) { - return 'true'; + return $var ? 'true' : 'false'; } else { - return 'false'; + return $var; } } diff --git a/include/dblayer/functions_pgsql.inc.php b/include/dblayer/functions_pgsql.inc.php index 5e05fb16a..38fcc2ed9 100644 --- a/include/dblayer/functions_pgsql.inc.php +++ b/include/dblayer/functions_pgsql.inc.php @@ -510,13 +510,13 @@ function get_boolean( $string ) */ function boolean_to_string($var) { - if (!empty($var) && ($var == 't')) + if (is_bool($var)) { - return 'true'; + return $var ? 'true' : 'false'; } else { - return 'false'; + return $var; } } diff --git a/include/dblayer/functions_sqlite.inc.php b/include/dblayer/functions_sqlite.inc.php index 1b34d3fcb..9de81868d 100644 --- a/include/dblayer/functions_sqlite.inc.php +++ b/include/dblayer/functions_sqlite.inc.php @@ -479,13 +479,13 @@ function get_boolean( $string ) */ function boolean_to_string($var) { - if (!empty($var) && ($var == 'true')) + if (is_bool($var)) { - return 'true'; + return $var ? 'true' : 'false'; } else { - return 'false'; + return $var; } } -- cgit v1.2.3