Changeset 34596

Show
Ignore:
Timestamp:
07/24/09 11:06:23 (4 years ago)
Author:
nowelium
Message:

merge IN(?,?,...) and VALUES(?,?,...)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • platform/mysql/mprofile.php/trunk/mpfilter.php

    r34577 r34596  
    44$replacement = array( 
    55    '/\r?\n/' => ' ', 
     6    '/((?<=\W)-?(?:0x[0-9a-f]+))/i' => '?', 
    67    '/(\"([^\"]+)\")/' => '?', 
    78    '/(\'([^\']+)\')/' => '?', 
    89    '/\s{2,}/' => ' ' 
    9  
    1010); 
    1111$replacepattern = array_keys($replacement); 
    1212$replace = array_values($replacement); 
     13 
     14function __replace_place_folder__($matches){ 
     15    $buf = $matches[2]; 
     16    $buf = preg_replace('/(([^\,\s\(\)\?]+))+/', '?', $buf); 
     17    return $matches[1] . ' ' . $buf; 
     18} 
    1319 
    1420$stdin = fopen('php://stdin', 'r'); 
     
    2329    } 
    2430    foreach($rows as $row){ 
    25         $returnValue[] = preg_replace($replacepattern, $replace, $row->Info); 
     31        if(!isset($row->Info)){ 
     32            continue; 
     33        } 
     34        $info = $row->Info; 
     35        $info = preg_replace($replacepattern, $replace, $info); 
     36        $info = preg_replace_callback('/(VALUES|IN)\s*(\(.*\))/i', '__replace_place_folder__',  $info); 
     37        $returnValue[] = $info; 
    2638    } 
    2739    echo json_encode($returnValue), PHP_EOL;