From c8e322d88f8195727c18eac90d30a5919e6fb8a0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 12:41:26 +0200 Subject: [ticket/10942] Fix sql_conditional for mssql, postgre and oracle PHPBB3-10942 --- phpBB/includes/db/postgres.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'phpBB/includes/db/postgres.php') diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php index dddf615f9c..a27fbb9d9f 100644 --- a/phpBB/includes/db/postgres.php +++ b/phpBB/includes/db/postgres.php @@ -154,6 +154,18 @@ class dbal_postgres extends dbal return ($raw) ? $this->sql_server_version : 'PostgreSQL ' . $this->sql_server_version; } + /** + * {@inheritDoc} + */ + function sql_conditional($condition, $action_true, $action_false = false) + { + $sql_condition = 'CASE WHEN ' . $condition; + $sql_condition .= ' THEN CAST(' . $action_true . ' AS TEXT)'; + $sql_condition .= ($action_false !== false) ? ' ELSE CAST(' . $action_false . ' AS TEXT)' : ''; + $sql_condition .= ' END'; + return $sql_condition; + } + /** * {@inheritDoc} */ -- cgit v1.2.1