diff options
| -rw-r--r-- | docs/changelog.md | 1 | ||||
| -rw-r--r-- | drivers/adodb-odbc_mssql.inc.php | 29 |
2 files changed, 30 insertions, 0 deletions
diff --git a/docs/changelog.md b/docs/changelog.md index e230cce9..5718c095 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -44,6 +44,7 @@ Older changelogs: - mysqli: method failed if $associative set true. #181 - mysqli: return fields as ADOFieldObject objects. #175 - odbc/mssql: fix null strings concatenation issue with SQL server 2012. #148 +- odbc/mssql: add missing Concat() method. #402 - odbc: MetaColumns() can optionally be set to return MetaType for backwards compatibility. #184 - pdo: allow loading of subclassed recordset. #245 - pdo: add setConnectionParameter support. #247 diff --git a/drivers/adodb-odbc_mssql.inc.php b/drivers/adodb-odbc_mssql.inc.php index bc28d261..8612dd71 100644 --- a/drivers/adodb-odbc_mssql.inc.php +++ b/drivers/adodb-odbc_mssql.inc.php @@ -395,6 +395,35 @@ order by constraint_name, referenced_table_name, keyno"; { return ADODB_STRINGMAX_NOLIMIT; } + + // returns concatenated string + // MSSQL requires integers to be cast as strings + // automatically cast every datatype to VARCHAR(255) + // @author David Rogers (introspectshun) + function Concat() + { + $s = ""; + $arr = func_get_args(); + + // Split single record on commas, if possible + if (sizeof($arr) == 1) { + foreach ($arr as $arg) { + $args = explode(',', $arg); + } + $arr = $args; + } + + array_walk( + $arr, + function(&$value, $key) { + $value = "CAST(" . $value . " AS VARCHAR(255))"; + } + ); + $s = implode('+',$arr); + if (sizeof($arr) > 0) return "$s"; + + return ''; + } } |
