Welcome Guest, Not a member yet? Register   Sign In
Please help with setting $this->_protect_identifiers to false
#1

[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.



#2

[eluser]Unknown[/eluser]
Anyone could help?

CI used to set $this->_protect_identifiers by the second parameter to the function select(), but in the latest version, I didn't find a way. Is it a bug or did I miss anything?

Or if there's another way to solve this, please help. I really appreciate it.




Theme © iAndrew 2016 - Forum software by © MyBB