Database access with wrong types...

MySQL accepts whatever and automatically converts types, but not PostgreSQL.

I have a site where the source parameter is set to 3 (somehow) and that's detected as a numeric value and thus converted to %d. Unfortunately for me, source is a string...

function boost_path_redirect_load($where = array(), $args = array(), $sort = array()) {
  $redirects = array();
  if (is_numeric($where)) {
    $where = array('rid' => $where);
  }

  foreach ($where as $key => $value) {
    if (is_string($key)) {
      $args[] = $value;
///
/// Assumption that $value as the correct type
///
      $where[$key] = $key .' = '. (is_numeric($value) ? '%d' : "'%s'");
///
///
///
    }
  }

  if ($where && $args) {
    $sql = "SELECT * FROM {path_redirect} WHERE ". implode(' AND ', $where);
    if ($sort) {
      $sql .= ' ORDER BY '. implode(' ,', $sort);
    }
    $result = db_query($sql, $args);
    while ($redirect = db_fetch_array($result)) {
      $redirects[] = $redirect;
    }
    return $redirects;
  }
}

Thank you.
Alexis