Welcome Guest, Not a member yet? Register   Sign In
Postgres Error after update to 1.7.2
#1

[eluser]Milaan[/eluser]
Hello,

after the update to CI 1.7.2 i get the following error:

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_DB_postgre_driver::$_like_escape_char

Filename: database/DB_active_rec.php

Line Number: 728

Any idea what is causing this?
#2

[eluser]Milaan[/eluser]
Hmmm looks like $this->_like_escape_char is undefined in this function...
Code:
// --------------------------------------------------------------------

    /**
     * Like
     *
     * Called by like() or orlike()
     *
     * @access    private
     * @param    mixed
     * @param    mixed
     * @param    string
     * @return    object
     */
    function _like($field, $match = '', $type = 'AND ', $side = 'both', $not = '')
    {
        if ( ! is_array($field))
        {
            $field = array($field => $match);
        }
    
        foreach ($field as $k => $v)
        {
            $k = $this->_protect_identifiers($k);

            $prefix = (count($this->ar_like) == 0) ? '' : $type;

            $v = $this->escape_like_str($v);

            if ($side == 'before')
            {
                $like_statement = $prefix." $k $not LIKE '%{$v}'";
            }
            elseif ($side == 'after')
            {
                $like_statement = $prefix." $k $not LIKE '{$v}%'";
            }
            else
            {
                $like_statement = $prefix." $k $not LIKE '%{$v}%'";
            }
            
            // some platforms require an escape sequence definition for LIKE wildcards
            if ($this->_like_escape_str != '')
            {
                $like_statement = $like_statement.sprintf($this->_like_escape_str, $this->_like_escape_char);
            }
            
            $this->ar_like[] = $like_statement;
            if ($this->ar_caching === TRUE)
            {
                $this->ar_cache_like[] = $like_statement;
                $this->ar_cache_exists[] = 'like';
            }
            
        }
        return $this;
    }
#3

[eluser]Milaan[/eluser]
Can anyone help?
#4

[eluser]wabu[/eluser]
I was able to reproduce the error with the like() function using CI Rev. 1746 (2009-09-17). It appears that '_like_escape_char' really isn't defined anywhere in CI.

This variable doesn't exist in 1.7.1 so it must be new to 1.7.2 (Change Log mentions the new 'like' stuff).
#5

[eluser]Milaan[/eluser]
Can anyone from EllisLab confirm this Bug and maybe post a quick fix ??? Thanks.
#6

[eluser]wabu[/eluser]
All the driver files define '$_like_escape_chr' (not '$_like_escape_char') so it appears it's a simple error.

See:

- postgre_driver.php
- mysql_driver.php
- etc.
#7

[eluser]Milaan[/eluser]
OK, its possible to fix this temporarly

Code:
725 // some platforms require an escape sequence definition for LIKE wildcards
726    if ($this->_like_escape_str != '')
727 {
728        $like_statement = $like_statement.sprintf($this->_like_escape_str, @$this->_like_escape_char);
729 }

Just add an @ before _like_escape_char in line 728
#8

[eluser]Unknown[/eluser]
Well, i've got the same error with my DB_active_rec.php and oci8_driver.php on the same line 728.

why use @ if the cure is to spell the variable well ?

i corrected the variable.
it works.

maybe, i'll try to find where to report this bug.
#9

[eluser]Eddie Monge[/eluser]
Here's where all the misspelled characters are:

Search "_like_escape_char" (6 hits in 6 files)

system\database\DB_active_rec.php (1 hits)
Line 728:
$like_statement = $like_statement.sprintf($this->_like_escape_str, $this->_like_escape_char);


system\database\drivers\mssql\mssql_driver.php (1 hits)
Line 392:
//$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char);


system\database\drivers\oci8\oci8_driver.php (1 hits)
Line 496:
$sql .= " WHERE TABLE_NAME LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char);


system\database\drivers\odbc\odbc_driver.php (1 hits)
Line 365:
//$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char);


system\database\drivers\postgre\postgre_driver.php (1 hits)
Line 408:
$sql .= " AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char);


system\database\drivers\sqlite\sqlite_driver.php (1 hits)
Line 377:
$sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char);




Theme © iAndrew 2016 - Forum software by © MyBB