Merge pull request #1177 from Eclarian/feature/db_toString_support
Adding Support to Properly Escape Objects that have __toString() magic method
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 12cd391..bcff433 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -670,7 +670,7 @@
*/
public function escape($str)
{
- if (is_string($str))
+ if (is_string($str) OR method_exists($str, '__toString'))
{
$str = "'".$this->escape_str($str)."'";
}