Ticket #356: ANSI config patch.diff

File ANSI config patch.diff, 1.8 kB (added by adam@…, 3 years ago)

Patch to make property updates conform to ANSI SQL

  • reader/cls/config.php

     
    144144                               return false; 
    145145                       } 
    146146                       $val = rss_real_escape_string($val); 
    147                        rss_query('insert into ' .getTable('properties')  
    148                        .'(fk_ref_object_id, proptype, property, value) values (' 
    149                        ."'$ref_obj','$type','$prop','$val'" 
    150                        .')' 
    151                        // I hope this is ANSI! 
    152                        . " ON DUPLICATE KEY UPDATE value='$val'" 
    153                        ); 
     147 
     148                       $res = rss_query('SELECT count(fk_ref_object_id) FROM ' .getTable('properties') 
     149                       ." WHERE fk_ref_object_id = '$ref_obj' AND proptype = '$type'" 
     150                       ." AND property = '$prop'"); 
     151            list ($cnt_rows) = rss_fetch_row($res); 
     152 
     153            if ($cnt_rows) { 
     154                               rss_query('UPDATE ' .getTable('properties')  
     155                               ." SET value = '$val' WHERE fk_ref_object_id = '$ref_obj' AND proptype = '$type'" 
     156                               ." AND property = '$prop'"); 
     157                       } else { 
     158                               rss_query('insert into ' .getTable('properties')  
     159                               .'(fk_ref_object_id, proptype, property, value) values (' 
     160                               ."'$ref_obj','$type','$prop','$val'" 
     161                               .')'); 
     162                       } 
    154163                       $this -> _populateProperties(); 
    155164                       rss_invalidate_cache(); 
    156165                       return true;