Uploaded image for project: 'Doctrine 1'
  1. Doctrine 1
  2. DC-675

Doctrine_Connection_Mssql charset problem


    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.3
    • Component/s: None
    • Labels:


      Recently I got problems with converting UTF-8 data to iso ISO-8859-1 while trying to insert/update a Microsoft SQL Server database.
      I wrote a task that exports data from an UTF-8 MySQL database to a latin1 Microsoft SQL Server database. When converting the data from UTF-8 to ISO-8859-1 the insert/update fails:

      SQLSTATE[HY000]: General error: trying to execute an empty query

      As i tracked the error down I realized, that the exception only occurs if I try to insert/update data with special characters like "ü", "ö", "ä", "ß" etc.
      The error's origin seems to lie in the Doctrine_Connection_Mssql class, more precisely in the replaceBoundParamsWithInlineValuesInQuery() method.
      Debugging this method shows that after replacing a bound param with data containing a special character (see above), the replace action for the next bound param replaces the whole query string with an empty string. Therefore the parent class's method exec() throws an exception as it tries to execute an empty query.


      Task snippet:
      // $src is UTF-8 data (MySQL DB)
      // $dest ist latin1 data (MSSQL DB)

      $dest->setCity(iconv("UTF-8", "ISO-8859-1//TRANSLIT", $src->getCity());
      $dest->setStreet(iconv("UTF-8", "ISO-8859-1//TRANSLIT", $src->getStreet());

      RESULTING DQL: UPDATE table SET zip = ?, city = ?, street = ? WHERE id = ?;

      'Dummystreet 18'

      After replaceBoundParamsWithInlineValuesInQuery() replaces param 'München', the query string is replaced by an empty string in the following iteration.

      The root of the Problem seems to lie in the regex modifier 'u' which treats the pattern as UTF-8 in the param replacements. Removing this modifier solves the problem for me. What purpose has this modifier?


        There are no comments yet on this issue.


          • Assignee:
            jwage Jonathan H. Wage
            deeky Steve Müller
          • Votes:
            0 Vote for this issue
            2 Start watching this issue


            • Created: