6.0.0-git
2021-01-18

[#1816] databinding broken on mssql -- Horde_SQL class
Summary databinding broken on mssql -- Horde_SQL class
Queue Horde Base
Queue Version 3.0.4
Type Bug
State Resolved
Priority 3. High
Owners
Requester luke (at) softserve (dot) com (dot) au
Created 2005-04-18 (5754 days ago)
Due
Updated 2005-04-19 (5753 days ago)
Assigned
Resolved 2005-04-19 (5753 days ago)
Milestone
Patch No

History
2005-04-19 21:49:45 luke (at) softserve (dot) com (dot) au Comment #3 Reply to this comment
Thanks. Sorry, I'm not yet familiar enough with Horde to get into the 
CVS side of it and I couldn't see a similar bug here.
2005-04-19 07:47:42 Jan Schneider Comment #2
State ⇒ Resolved
Reply to this comment
Fixed in CVS and Horde 3.0.5. The wrong placeholder had been fixed already.
2005-04-18 23:52:56 luke (at) softserve (dot) com (dot) au Comment #1
Type ⇒ Bug
State ⇒ Unconfirmed
Priority ⇒ 3. High
Summary ⇒ databinding broken on mssql -- Horde_SQL class
Queue ⇒ Horde Base
Reply to this comment
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.

Saved Queries