title: Do custom functions not work with PHP PDO prepare/execute methods?
body: <p>I'm writing a script with PHP PDO/SQLite that takes user-inputted zipcode, and using <a href="https://stackoverflow.com/questions/2083182/calculating-great-circle-distance-with-sqlite/16032915#16032915">this distance function</a> return all the locations within a certain radius and other criteria.  I first wrote it just using a regular query method and it worked fine.  But then I decided it's a good idea to sanitize it with the prepare/execute methods.  When I did that, the radius search broke.  All the other criteria worked fine, and if I changed the location to a straight match (not using the distance function) it worked as well.  But if I use the custom function and the prepare/execute... the radius function always returns true.  Has anyone else experienced this?</p>
  
  <p>This code works:</p>
  
  <pre><code>db-&gt;sqliteCreateFunction('distance', function () {
      if (count($geo = array_map('deg2rad', array_filter(func_get_args(), 'is_numeric'))) == 4) {
          return round(acos(sin($geo[0]) * sin($geo[2]) + cos($geo[0]) * cos($geo[2]) * cos($geo[1] - $geo[3])) * 6378.14, 3);
      }
      return null;
  }, 4);
  
  $searches=array();
  if(isset($_POST['specialty'])) {
      $searches['specialty'] = "specialtyID = $_POST[specialty]";
  }
  if (isset($_POST['name'])) {
      $searches['name'] = "name LIKE \"%$_POST[name]%\"";
  }
  if (isset($_POST['postalCode'])) {
      // leaving out code that sets $lat,$lon
      $searches['postalCode'] = "distance('$lat','$lon',lat,lon)&lt;:$_POST[postalCodeRadius]";
  }
  
  $query="SELECT * FROM providers WHERE ".implode(" AND ",$searches);
  $result = db-&gt;query($query)-&gt;fetchAll();
  </code></pre>
  
  <p>This code does not work for postalCode (but does for specialty and name):</p>
  
  <pre><code>// leaving out same create function code
  
  $searches=array();
  $postdata=array();
  if(isset($_POST['specialty'])) {
      $searches['specialty'] = "specialtyID = :specialty";
      $postdata['specialty']=$_POST['specialty'];
  }
  if (isset($_POST['name'])) {
      $searches['name'] = "name LIKE \"%$_POST[name]%\"";
      $postdata['name']="%$_POST[name]%";
  }
  if (isset($_POST['postalCode'])) {
      // leaving out code that sets $lat,$lon
      $searches['postalCode'] = "distance('$lat','$lon',lat,lon)&lt;:postalCodeRadius";
      $postdata['postalCodeRadius']=$_POST['postalCodeRadius'];
  }
  
  $sth = $primecare_db-&gt;prepare("SELECT * FROM providers WHERE ".implode(" AND ",$searches));
  $sth-&gt;execute($postdata);
  $result = $sth-&gt;fetchAll();
  </code></pre>