title: php post: replace single quote with double single for sqlserver query
body: <p>my <code>$POST</code> value is "WYNN'S". When I create an sql query via Yii2 framework:</p>
  
  <pre><code>$vendor = (new Query()) -&gt;select('VendorNo') -&gt;distinct() -&gt;from('Pm_Item i') -&gt;innerJoin('[PurchPrice] [p]', 'p.ItemNo = i.ItemNo AND p.CompanyKey = i.CompanyKey') -&gt;where($condition)-&gt;all();
  </code></pre>
  
  <p>i get an error: </p>
  
  <p><code>Incorrect syntax near 'S'.
  The SQL being executed was: SELECT DISTINCT [TopCode] FROM [PM_Item] WHERE  Brand IN( 'WYNN'S')</code></p>
  
  <p>How can I replace 'WYNN'S' with 'WYNN''S' using php?</p>
  
  <p>UPDATE: </p>
  
  <pre><code>    $condition = '';
      $i = 0;
      foreach ($filters as $filter) {
          if (isset($filter['selected'])) {
              if (strpos( $filter['selected']['value'], "'") !== false) {
                  $filter['selected']['value'] =  str_replace("'", "''", $filter['selected']['value']); //preg_replace('/\'/', '\'\'', $filter['selected']['value']);
              }
              if ($i != 0 AND $filter['selected']['value'] != '') {
                  $condition .= ' AND i.' . $filter['column'] . ' = \'' . $filter['selected']['value'] . '\'';
              } elseif ($filter['selected']['value'] != '') {
                  $condition .= 'i.' . $filter['column'] . ' = \'' . $filter['selected']['value'] . '\'';
              }
  
              $i++;
          }
      }
  </code></pre>