system/Database/BaseConnection.php
public function escape($str)
	{
		if (is_array($str))
		{
			$str = array_map([&$this, 'escape'], $str);

			return $str;
		}
		else if (is_string($str) || ( is_object($str) && method_exists($str, '__toString')))
		{
			return "'" . $this->escapeString($str) . "'";
		}
		else if (is_bool($str))
		{
			return ($str === false) ? 0 : 1;
		}
		else if (is_numeric($str) && $str < 0)
		{
			return "'{$str}'";
		}
		else if ($str === null)
		{
			return 'NULL';
		}

		return $str;
	}
public function escape($str)
	{
		if (is_array($str))
		{
			$str = array_map([&$this, 'escape'], $str);

			return $str;
		}
		else if (is_string($str) || ( is_object($str) && method_exists($str, '__toString')))
		{
			return "'" . $this->escapeString($str) . "'";
		}
		else if (is_bool($str))
		{
			return ($str === false) ? 0 : 1;
		}
		else if (is_numeric($str) && $str < 0)
		{
			return "'{$str}'";
		}
		else if ($str === null)
		{
			return 'NULL';
		}

		return $str;
	}
"Smart" Escape String

Escapes data based on type.
Sets boolean and null types

@param mixed $str

@return mixed