[eluser]Unknown[/eluser]
I encountered a database error when running sql like
Code:
$query = $this->db->select("id, message_id, send_time", false)
->where_in("id", $ids)
->where("type_id", $type)
->group_by("concat(id,' ',mail_id)")
->get("mylog");
The error occurs at group_by("..."), where backsticks are added in incorrect positions.
Code:
GROUP BY concat(id, `'` ', `mail_id)`
When I looked into CI 2.1.2 and found the following:
1. the variable $_protect_identifiers in system/database/DB_driver.php, by default, is TRUE.
2. there is no other place under systems/ directory to set
$this->_protect_identifiers; But in CI 1.7.0, it has the following in function select() in system/database/DB_active_rec.php, where the variable can be assigned by the parameter $escape.
Code:
function select($select = '*', $escape = NULL)
{
// Set the global value if this was sepecified
if (is_bool($escape))
{
$this->_protect_identifiers = $escape;
}
I wonder if anyone could help to solve the database error when using
concat in '
group_by()'?
Thank you in advance.