diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2012-07-18 11:07:32 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2012-07-18 11:07:32 +0200 |
commit | f4136eacdc319b2029692a9c19a845a115b94129 (patch) | |
tree | f610d14df9e80ee74e8b35e4e8b8183170555f02 /phpBB/includes/db/dbal.php | |
parent | 3637cd395e39c1fa5b7279222abe1da5d2abcd00 (diff) | |
parent | b176b86f111a05338ed3c74026bcf19d42ec0ee3 (diff) | |
download | forums-f4136eacdc319b2029692a9c19a845a115b94129.tar forums-f4136eacdc319b2029692a9c19a845a115b94129.tar.gz forums-f4136eacdc319b2029692a9c19a845a115b94129.tar.bz2 forums-f4136eacdc319b2029692a9c19a845a115b94129.tar.xz forums-f4136eacdc319b2029692a9c19a845a115b94129.zip |
Merge branch 'develop' of git://github.com/phpbb/phpbb3 into feature/new-tz-handling
Diffstat (limited to 'phpBB/includes/db/dbal.php')
-rw-r--r-- | phpBB/includes/db/dbal.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index cf54d455f7..159703d3be 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -284,6 +284,37 @@ class dbal } /** + * Build a case expression + * + * Note: The two statements action_true and action_false must have the same data type (int, vchar, ...) in the database! + * + * @param string $condition The condition which must be true, to use action_true rather then action_else + * @param string $action_true SQL expression that is used, if the condition is true + * @param string $action_else SQL expression that is used, if the condition is false, optional + * @return string CASE expression including the condition and statements + */ + public function sql_case($condition, $action_true, $action_false = false) + { + $sql_case = 'CASE WHEN ' . $condition; + $sql_case .= ' THEN ' . $action_true; + $sql_case .= ($action_false !== false) ? ' ELSE ' . $action_false : ''; + $sql_case .= ' END'; + return $sql_case; + } + + /** + * Build a concatenated expression + * + * @param string $expr1 Base SQL expression where we append the second one + * @param string $expr2 SQL expression that is appended to the first expression + * @return string Concatenated string + */ + public function sql_concatenate($expr1, $expr2) + { + return $expr1 . ' || ' . $expr2; + } + + /** * Returns whether results of a query need to be buffered to run a transaction while iterating over them. * * @return bool Whether buffering is required. |