summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/odbc/odbc_driver.php
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2008-01-16 23:22:42 +0100
committerDerek Allard <derek.allard@ellislab.com>2008-01-16 23:22:42 +0100
commit6157938ad5dd9d48607921593ca4ed7bff3e3a8b (patch)
tree51a3c6479a1027ae433b31019aea5cbbe8cfe614 /system/database/drivers/odbc/odbc_driver.php
parentcdbdf2d30dd1dd6aff2ea25e9875814080d416e2 (diff)
Diffstat (limited to 'system/database/drivers/odbc/odbc_driver.php')
-rw-r--r--system/database/drivers/odbc/odbc_driver.php15
1 files changed, 8 insertions, 7 deletions
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 0bdfc41d5..c5c582d0b 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -422,27 +422,28 @@ class CI_DB_odbc_driver extends CI_DB {
// This function may get "item1 item2" as a string, and so
// we may need "`item1` `item2`" and not "`item1 item2`"
- if (strpos($item, ' ') !== FALSE)
+ if (ctype_alnum($item) === FALSE)
{
// This function may get "field >= 1", and need it to return "`field` >= 1"
- if ($first_word_only === TRUE)
- {
- return '`'.preg_replace('/ /', '` ', $item, 1);
- }
+ $lbound = ($first_word_only === TRUE) ? '' : '|\s|\(';
- $item = preg_replace('/(^|\s|\()([\w\d\-\_]+?)(\s|\)|$)/iS', '$1`$2`$3', $item);
+ $item = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1`$2`$3', $item);
+ }
+ else
+ {
+ return "`{$item}`";
}
$exceptions = array('AS', '/', '-', '%', '+', '*');
foreach ($exceptions as $exception)
{
+
if (stristr($item, " `{$exception}` ") !== FALSE)
{
$item = preg_replace('/ `('.preg_quote($exception).')` /i', ' $1 ', $item);
}
}
-
return $item;
}