Welcome Guest, Not a member yet? Register   Sign In
Problem connecting to MS SQL Server
#4

[eluser]polaris1927[/eluser]
If you are running version 1.6.1 modify the mssql_driver.php file as follows:


Code:
Discovered the cause.

Version 1.6.0, Module: mssql_driver


function _protect_identifiers($item, $affect_spaces = TRUE, $first_word_only = FALSE)
{
    // MSSQL doesn't use backticks
    return $item;
}

Was replaced in Version 1.6.1 with:


function _protect_identifiers($item, $first_word_only = FALSE)
{
    
    if (is_array($item))
    {    
        $escaped_array = array();

        foreach($item as $k=>$v)
        {
            $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v, $first_word_only);
        }

        return $escaped_array;
    }    

    // This function may get "item1 item2" as a string, and so
    // we may need ""item1" "item2"" and not ""item1 item2""
    if (ctype_alnum($item) === FALSE)
    {
        if (strpos($item, '.') !== FALSE)
        {
            $aliased_tables = implode(".",$this->ar_aliased_tables).'.';
            $table_name =  substr($item, 0, strpos($item, '.')+1);
            $item = (strpos($aliased_tables, $table_name) !== FALSE) ? $item = $item : $this->dbprefix.$item;
        }

        // This function may get "field >= 1", and need it to return ""field" >= 1"
        $lbound = ($first_word_only === TRUE) ? '' : '|\s|\(';

        $item;// = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1"$2"$3', $item);
    }
    else
    {
        
        return "\"{$item}\"";
    }

    $exceptions = array('AS', '/', '-', '%', '+', '*');
        
    foreach ($exceptions as $exception)
    {
        
        if (stristr($item, " \"{$exception}\" ") !== FALSE)
        {
            $item = preg_replace('/ "('.preg_quote($exception).')" /i', ' $1 ', $item);
        }
    }
    return $item;
}

For a quick fix i reverted to the 1.6.0 code.

JC


Messages In This Thread
Problem connecting to MS SQL Server - by El Forum - 03-10-2008, 06:13 AM
Problem connecting to MS SQL Server - by El Forum - 03-10-2008, 06:49 AM
Problem connecting to MS SQL Server - by El Forum - 03-10-2008, 12:15 PM
Problem connecting to MS SQL Server - by El Forum - 03-10-2008, 01:05 PM
Problem connecting to MS SQL Server - by El Forum - 03-10-2008, 01:30 PM
Problem connecting to MS SQL Server - by El Forum - 03-13-2008, 01:53 PM
Problem connecting to MS SQL Server - by El Forum - 03-15-2008, 04:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB