Welcome Guest, Not a member yet? Register   Sign In
Database class adding graves ("`") where they don't belong
#3

[eluser]mattalexx[/eluser]
[quote author="fesweb" date="1226717587"]You can make it stop that by passing an extra parameter (FALSE) to the db function.

Example using a different function - in this case, it's the third parameter:
Code:
$where = "LEFT(`p`.`name_last`, 1) <= 'g'";
$this->db->where($where, NULL, FALSE);

Good luck...[/quote]

I'm trying to use the join function, not the where function.

I see that the where function has an "escape" parameter:
Code:
// ci_1.7.0/database/DB_active_rec.php, line 354

    function where($key, $value = NULL, $escape = TRUE)
    {
        return $this->_where($key, $value, 'AND ', $escape);
    }
... but the join function does not:
Code:
// ci_1.7.0/database/DB_active_rec.php, line 299

    function join($table, $cond, $type = '')
    {        
        if ($type != '')
        {
            $type = strtoupper(trim($type));

            if ( ! in_array($type, array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER')))
            {
                $type = '';
            }
            else
            {
                $type .= ' ';
            }
        }

        // Extract any aliases that might exist.  We use this information
        // in the _protect_identifiers to know whether to add a table prefix
        $this->_track_aliases($table);

        // Strip apart the condition and protect the identifiers
        if (preg_match('/([\w\.]+)([\W\s]+)(.+)/', $cond, $match))
        {
            $match[1] = $this->_protect_identifiers($match[1]);
            $match[3] = $this->_protect_identifiers($match[3]);
        
            $cond = $match[1].$match[2].$match[3];        
        }
        
        // Assemble the JOIN statement
        $join = $type.'JOIN '.$this->_protect_identifiers($table, TRUE, NULL, FALSE).' ON '.$cond;

        $this->ar_join[] = $join;
        if ($this->ar_caching === TRUE)
        {
            $this->ar_cache_join[] = $join;
            $this->ar_cache_exists[] = 'join';
        }

        return $this;
    }


Messages In This Thread
Database class adding graves ("`") where they don't belong - by El Forum - 11-14-2008, 03:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB