[Tickets #1816] NEW: databinding broken on mssql -- Horde_SQL class

bugs at bugs.horde.org bugs at bugs.horde.org
Mon Apr 18 16:52:56 PDT 2005


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/?id=1816
-----------------------------------------------------------------------
 Ticket             | 1816
 Created By         | luke at softserve.com.au
 Summary            | databinding broken on mssql -- Horde_SQL class
 Queue              | Horde Base
 Version            | 3.0.4
 State              | Unconfirmed
 Priority           | 3. High
 Type               | Bug
 Owners             | 
-----------------------------------------------------------------------


luke at softserve.com.au (2005-04-18 16:52) wrote:

The buildClause function in Horde_SQL does not correctly handle bitwise
operators with mssql. The same code as is implemented for ODBC should be
used against mssql.

Furthermore, there is a bug in the ODBC code ... when $bind = true, it tries
to feed a '?' string through a %d field in sprintf. This forces the
generated SQL to "0" rather than "?", thereby breaking databinding. It
appears the same bug will eventually appear against oci8 too, as the code is
very similar. I've patched this for mssql by changing:

case 'odbc':
    // ODBC must have a valid boolean expression
    $query = '(%s & %d) = %d';
    if ($bind) {
        return array(sprintf(Horde_SQL::escapePrepare($query),
                             Horde_SQL::escapePrepare($lhs), '?', '?'),
                     array((int)$rhs, (int)$rhs));
    } else {
        return sprintf($query, $lhs, (int)$rhs, (int)$rhs);
    }

to:

case 'odbc':
case 'mssql':
    // ODBC must have a valid boolean expression
    if ($bind) {
        $query = '(%s & %s) = %s';
        return array(sprintf(Horde_SQL::escapePrepare($query),
                             Horde_SQL::escapePrepare($lhs), '?', '?'),
                     array((int)$rhs, (int)$rhs));
    } else {
        $query = '(%s & %d) = %d';
        return sprintf($query, $lhs, (int)$rhs, (int)$rhs);
    }

Without this fix, no datatree functionality exists.




More information about the bugs mailing list