Changeset 380


Ignore:
Timestamp:
Mar 11, 2010, 7:21:43 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Správně vylomítkování podřetězce SQL dotazu při volání exportu.
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • tools/dbc_export/DBCExport.lpi

    r370 r380  
    22<CONFIG>
    33  <ProjectOptions>
    4     <PathDelim Value="/"/>
    54    <Version Value="7"/>
    65    <General>
     
    1716      <Language Value=""/>
    1817      <CharSet Value=""/>
     18      <StringTable Comments="" CompanyName="" FileDescription="" FileVersion="0.0.0.0" InternalName="" LegalCopyright="" LegalTrademarks="" OriginalFilename="" ProductName="" ProductVersion="0.0.0.0"/>
    1919    </VersionInfo>
    2020    <PublishOptions>
     
    3131      </local>
    3232    </RunParams>
    33     <Units Count="17">
     33    <Units Count="18">
    3434      <Unit0>
    3535        <Filename Value="DBCExport.pas"/>
    3636        <IsPartOfProject Value="True"/>
    3737        <UnitName Value="DBCExport"/>
    38         <CursorPos X="45" Y="168"/>
    39         <TopLine Value="144"/>
     38        <CursorPos X="49" Y="84"/>
     39        <TopLine Value="58"/>
    4040        <EditorIndex Value="0"/>
    4141        <UsageCount Value="80"/>
     
    115115        <IsPartOfProject Value="True"/>
    116116        <UnitName Value="USqlDatabase"/>
    117         <CursorPos X="14" Y="53"/>
    118         <TopLine Value="10"/>
    119         <EditorIndex Value="3"/>
     117        <CursorPos X="13" Y="308"/>
     118        <TopLine Value="222"/>
    120119        <UsageCount Value="71"/>
    121         <Loaded Value="True"/>
    122120        <SyntaxHighlighter Value="Delphi"/>
    123121      </Unit11>
     
    128126        <CursorPos X="27" Y="139"/>
    129127        <TopLine Value="89"/>
    130         <EditorIndex Value="1"/>
    131128        <UsageCount Value="71"/>
    132         <Loaded Value="True"/>
    133129        <SyntaxHighlighter Value="Delphi"/>
    134130      </Unit12>
     
    138134        <CursorPos X="51" Y="8"/>
    139135        <TopLine Value="1"/>
    140         <EditorIndex Value="2"/>
    141136        <UsageCount Value="71"/>
    142         <Loaded Value="True"/>
    143137        <SyntaxHighlighter Value="None"/>
    144138      </Unit13>
     
    162156        <UsageCount Value="10"/>
    163157      </Unit16>
     158      <Unit17>
     159        <Filename Value="/usr/share/fpcsrc/rtl/objpas/sysutils/sysstrh.inc"/>
     160        <CursorPos X="28" Y="33"/>
     161        <TopLine Value="14"/>
     162        <UsageCount Value="10"/>
     163      </Unit17>
    164164    </Units>
    165     <JumpHistory Count="28" HistoryIndex="27">
     165    <JumpHistory Count="16" HistoryIndex="15">
    166166      <Position1>
    167167        <Filename Value="DBCExport.pas"/>
     
    173173      </Position2>
    174174      <Position3>
    175         <Filename Value="USqlDatabase.pas"/>
    176         <Caret Line="4" Column="18" TopLine="1"/>
     175        <Filename Value="DBCExport.pas"/>
     176        <Caret Line="212" Column="30" TopLine="190"/>
    177177      </Position3>
    178178      <Position4>
    179         <Filename Value="USqlDatabase.pas"/>
    180         <Caret Line="52" Column="24" TopLine="30"/>
     179        <Filename Value="DBCExport.pas"/>
     180        <Caret Line="197" Column="32" TopLine="191"/>
    181181      </Position4>
    182182      <Position5>
    183         <Filename Value="USqlDatabase.pas"/>
    184         <Caret Line="80" Column="45" TopLine="58"/>
     183        <Filename Value="DBCExport.pas"/>
     184        <Caret Line="195" Column="1" TopLine="173"/>
    185185      </Position5>
    186186      <Position6>
    187         <Filename Value="USqlDatabase.pas"/>
    188         <Caret Line="137" Column="21" TopLine="115"/>
     187        <Filename Value="DBCExport.pas"/>
     188        <Caret Line="196" Column="1" TopLine="174"/>
    189189      </Position6>
    190190      <Position7>
    191191        <Filename Value="DBCExport.pas"/>
    192         <Caret Line="212" Column="30" TopLine="190"/>
     192        <Caret Line="196" Column="37" TopLine="174"/>
    193193      </Position7>
    194194      <Position8>
    195195        <Filename Value="DBCExport.pas"/>
    196         <Caret Line="197" Column="32" TopLine="191"/>
     196        <Caret Line="29" Column="1" TopLine="10"/>
    197197      </Position8>
    198198      <Position9>
    199199        <Filename Value="DBCExport.pas"/>
    200         <Caret Line="195" Column="1" TopLine="173"/>
     200        <Caret Line="82" Column="29" TopLine="61"/>
    201201      </Position9>
    202202      <Position10>
    203         <Filename Value="USqlDatabase.pas"/>
    204         <Caret Line="181" Column="1" TopLine="159"/>
     203        <Filename Value="DBCExport.pas"/>
     204        <Caret Line="194" Column="1" TopLine="176"/>
    205205      </Position10>
    206206      <Position11>
    207         <Filename Value="USqlDatabase.pas"/>
    208         <Caret Line="183" Column="1" TopLine="161"/>
     207        <Filename Value="DBCExport.pas"/>
     208        <Caret Line="206" Column="23" TopLine="185"/>
    209209      </Position11>
    210210      <Position12>
    211         <Filename Value="USqlDatabase.pas"/>
    212         <Caret Line="184" Column="1" TopLine="162"/>
     211        <Filename Value="DBCExport.pas"/>
     212        <Caret Line="234" Column="42" TopLine="217"/>
    213213      </Position12>
    214214      <Position13>
    215         <Filename Value="USqlDatabase.pas"/>
    216         <Caret Line="186" Column="1" TopLine="164"/>
     215        <Filename Value="DBCExport.pas"/>
     216        <Caret Line="238" Column="29" TopLine="219"/>
    217217      </Position13>
    218218      <Position14>
    219         <Filename Value="USqlDatabase.pas"/>
    220         <Caret Line="188" Column="1" TopLine="166"/>
     219        <Filename Value="DBCExport.pas"/>
     220        <Caret Line="6" Column="92" TopLine="1"/>
    221221      </Position14>
    222222      <Position15>
    223         <Filename Value="USqlDatabase.pas"/>
    224         <Caret Line="190" Column="1" TopLine="168"/>
     223        <Filename Value="DBCExport.pas"/>
     224        <Caret Line="53" Column="89" TopLine="19"/>
    225225      </Position15>
    226226      <Position16>
    227         <Filename Value="USqlDatabase.pas"/>
    228         <Caret Line="193" Column="1" TopLine="171"/>
     227        <Filename Value="DBCExport.pas"/>
     228        <Caret Line="83" Column="22" TopLine="59"/>
    229229      </Position16>
    230       <Position17>
    231         <Filename Value="USqlDatabase.pas"/>
    232         <Caret Line="194" Column="1" TopLine="172"/>
    233       </Position17>
    234       <Position18>
    235         <Filename Value="DBCExport.pas"/>
    236         <Caret Line="196" Column="1" TopLine="174"/>
    237       </Position18>
    238       <Position19>
    239         <Filename Value="USqlDatabase.pas"/>
    240         <Caret Line="179" Column="43" TopLine="1"/>
    241       </Position19>
    242       <Position20>
    243         <Filename Value="DBCExport.pas"/>
    244         <Caret Line="196" Column="37" TopLine="174"/>
    245       </Position20>
    246       <Position21>
    247         <Filename Value="DBCExport.pas"/>
    248         <Caret Line="29" Column="1" TopLine="10"/>
    249       </Position21>
    250       <Position22>
    251         <Filename Value="DBCExport.pas"/>
    252         <Caret Line="82" Column="29" TopLine="61"/>
    253       </Position22>
    254       <Position23>
    255         <Filename Value="DBCExport.pas"/>
    256         <Caret Line="194" Column="1" TopLine="176"/>
    257       </Position23>
    258       <Position24>
    259         <Filename Value="DBCExport.pas"/>
    260         <Caret Line="206" Column="23" TopLine="185"/>
    261       </Position24>
    262       <Position25>
    263         <Filename Value="DBCExport.pas"/>
    264         <Caret Line="234" Column="42" TopLine="217"/>
    265       </Position25>
    266       <Position26>
    267         <Filename Value="DBCExport.pas"/>
    268         <Caret Line="238" Column="29" TopLine="219"/>
    269       </Position26>
    270       <Position27>
    271         <Filename Value="DBCExport.pas"/>
    272         <Caret Line="6" Column="92" TopLine="1"/>
    273       </Position27>
    274       <Position28>
    275         <Filename Value="DBCExport.pas"/>
    276         <Caret Line="53" Column="89" TopLine="19"/>
    277       </Position28>
    278230    </JumpHistory>
    279231  </ProjectOptions>
  • tools/dbc_export/DBCExport.pas

    r370 r380  
    8181  if HasOption('q', 'sql_query') then begin
    8282    SQLquery := GetOptionValue('q', 'sql_query');
     83    SQLquery := StringReplace(SQLquery, '\ ', ' ', [rfReplaceAll]);
     84    SQLquery := StringReplace(SQLquery, '\`', '`', [rfReplaceAll]);
     85    WriteLn(SQLquery);
    8386  end;
    8487end;
     
    197200          for X := 1 to Length(ColumnTypeDefinition) do begin
    198201            if ColumnTypeDefinition[X] = 's' then begin
    199               Text := DBRows.Data[IndexRowData - 1].Values['text' + IntToStr(I)];
     202              Text := DBRows.Data[IndexRowData - 1].Values['Text' + IntToStr(I)];
    200203              SetString(Y, X - 1, Text);
    201204              I := I + 1;
     
    219222    Count := DBRows.Count;
    220223    for I := 1 to Count do begin
    221       Entry := StrToInt(DBRows.Data[i - 1].Values['entry']);
     224      Entry := StrToInt(DBRows.Data[I - 1].Values['Entry']);
    222225
    223226      if (I = 127) then SetLength(IndexTable, Entry + 1);
     
    238241  try
    239242    for I := 0 to DBRows.Count - 1 do begin
    240       if (StrToInt(DBRows.Data[i].Values['entry']) = Entry) then begin
     243      if (StrToInt(DBRows.Data[i].Values['Entry']) = Entry) then begin
    241244        Result := I;
    242245        Exit;
  • tools/dbc_export/USqlDatabase.pas

    r359 r380  
    306306begin
    307307  Table := ATable;
    308   DbResult = Query('DELETE FROM `' + Table + '` WHERE ' + Condition);
     308  DbResult := Query('DELETE FROM `' + Table + '` WHERE ' + Condition);
    309309  DbResult.Free;
    310310end;
  • trunk/export/export.php

    r377 r380  
    2525    if($DbResult->num_rows == 0) die('Export '.$this->Id.' neexistuje');
    2626    $this->Export = $DbResult->fetch_assoc();
    27 
     27   
    2828    // Filter selected languages
    2929    $this->WhereLang = '';
    3030    $DbResult = $this->Database->query('SELECT * FROM `ExportLanguage` WHERE `Export`='.$this->Id.' ORDER BY `Sequence`');
     31    echo($this->Database->error);
    3132    while($Language = $DbResult->fetch_assoc())
    32       $this->WhereLang .= ' OR (Language = '.$Language['Language'].')';
     33      $this->WhereLang .= ' OR (`Language` = '.$Language['Language'].')';
    3334    if($this->WhereLang == '') $this->WhereLang = 1;
    3435      else $this->WhereLang = '('.substr($this->WhereLang, 4).')';
     
    5253    } else
    5354    {
    54       $this->WhereUsers = '(User IN ('.$this->SelectedUsers.'))';
    55       $this->OrderByUserList = ' ORDER BY FIELD(User, '.$this->SelectedUsers.')';
     55      $this->WhereUsers = '(`User` IN ('.$this->SelectedUsers.'))';
     56      $this->OrderByUserList = ' ORDER BY FIELD(`User`, '.$this->SelectedUsers.')';
    5657    }
    5758   
     
    221222  function ExportToDBC()
    222223  {
    223     global $TranslationTree, $LanguageList,$Config;
     224    global $TranslationTree, $LanguageList, $Config;
    224225 
    225226    $this->LoadFilters();
    226227
    227228    $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`DBCFileName` != ""');
    228     while($Group = $DbResult->fetch_assoc())
    229     {
    230       echo($Group['Name'].'... ');
    231         if(file_exists('../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc')) {
    232                  
    233          $i = 1;
    234          $columns = '';
    235          foreach($TranslationTree[$Group['Id']]['Items'] as $Column) {
    236            $columns .= ' `T`.`'.$Column['Column'].'` AS `Text`'.$i.',';
    237            $i = $i+1;
    238          }
    239          
    240          $querty = '"SELECT '.$columns.' `T`.`Entry` AS `Entry` FROM (SELECT * FROM '.$Group['TablePrefix'].' WHERE (`Complete` = 1) AND '.$this->WhereLang.' AND '.$this->WhereUsers.' AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].')) AS `T` GROUP BY `T`.`Entry`"';
     229    echo('Počet generovaných skupin: '.$DbResult->num_rows.'<br/>'."\n");
     230    while($Group = $DbResult->fetch_assoc())
     231    {
     232      echo($Group['Name'].', ');
     233      if(file_exists('../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'))
     234      {
     235        $i = 1;
     236        $columns = '';
     237        foreach($TranslationTree[$Group['Id']]['Items'] as $Column)
     238        {
     239          $columns .= ' `T`.`'.$Column['Column'].'` AS `Text'.$i.'`,';
     240          $i = $i + 1;
     241        }
     242        $Query = 'SELECT '.$columns.' `T`.`Entry` AS `Entry` FROM (SELECT * FROM `'.$Group['TablePrefix'].'` WHERE (`Complete` = 1) AND '.$this->WhereLang.' AND '.$this->WhereUsers.' AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].')) AS `T` GROUP BY `T`.`Entry`';
     243        $Query = str_replace('`', '\`', $Query);
     244        $Query = '"'.str_replace(' ', '\ ', $Query).'"';
    241245     
    242        $params = '-u '.$Config['Database']['User'].' -p '.$Config['Database']['Password'].' -f ../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc -n '.$this->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc -c '.GetDBCColumns($this->ClientVersion['Version'], $Group['DBCFileName']).' -q '.$querty;
     246        $params = '-u '.$Config['Database']['User'].' -p '.$Config['Database']['Password'].' -f ../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc -n '.$this->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc -c '.GetDBCColumns($this->ClientVersion['Version'], $Group['DBCFileName']).' -q '.$Query;
    243247     
    244      //  echo('./DBCExport '.$params);
     248        //echo('./DBCExport '.$params);       
     249        exec('./DBCExport '.$params);
    245250       
    246        exec('./DBCExport '.$params);
    247        
    248       echo('Hotovo <br />
    249 ');
    250251      } else echo('Zdrojový soubor '.'../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'.' nenalezen.'."\n");
    251252    }
     253    echo('Hotovo <br />');
    252254  }
    253255
  • trunk/includes/global_function.php

    r376 r380  
    138138  }
    139139  return(array(
    140     'SQL' => ' ORDER BY '.$_SESSION['OrderCol'].' '.$OrderDirSQL[$_SESSION['OrderDir']],
     140    'SQL' => ' ORDER BY `'.$_SESSION['OrderCol'].'` '.$OrderDirSQL[$_SESSION['OrderDir']],
    141141    'Output' => '<tr>'.$Result.'</tr>',
    142142    'Column' => $_SESSION['OrderCol'],
  • trunk/save.php

    r376 r380  
    1616  $Language = $_POST['Language'] * 1;
    1717  if(array_key_exists('End', $_POST)) $Complete = 1;
    18     else $complete = 0;
     18    else $Complete = 0;
    1919             
    2020  $DbResult = $Database->SQLCommand('SELECT * FROM `'.$Table.'` WHERE (`Language` = 0) AND (`Entry` = '.$Entry.')');
Note: See TracChangeset for help on using the changeset viewer.