You are here

protected function OAuthStorePDO::sql_escape_string in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.2 lib/oauth-php/library/store/OAuthStorePDO.php \OAuthStorePDO::sql_escape_string()
  2. 7.3 lib/oauth-php/library/store/OAuthStorePDO.php \OAuthStorePDO::sql_escape_string()
  3. 7.4 lib/oauth-php/library/store/OAuthStorePDO.php \OAuthStorePDO::sql_escape_string()
  4. 7.5 lib/oauth-php/library/store/OAuthStorePDO.php \OAuthStorePDO::sql_escape_string()
  5. 7.6 lib/oauth-php/library/store/OAuthStorePDO.php \OAuthStorePDO::sql_escape_string()

Overrides OAuthStoreSQL::sql_escape_string

File

lib/oauth-php/library/store/OAuthStorePDO.php, line 211

Class

OAuthStorePDO

Code

protected function sql_escape_string($s) {
  if (is_string($s)) {
    $s = $this->conn
      ->quote($s);

    // kludge. Quote already adds quotes, and this conflicts with OAuthStoreSQL.
    // so remove the quotes
    $len = mb_strlen($s);
    if ($len == 0) {
      return $s;
    }
    $startcut = 0;
    while (isset($s[$startcut]) && $s[$startcut] == '\'') {
      $startcut++;
    }
    $endcut = $len - 1;
    while (isset($s[$endcut]) && $s[$endcut] == '\'') {
      $endcut--;
    }
    $s = mb_substr($s, $startcut, $endcut - $startcut + 1);
    return $s;
  }
  else {
    if (is_null($s)) {
      return NULL;
    }
    else {
      if (is_bool($s)) {
        return intval($s);
      }
      else {
        if (is_int($s) || is_float($s)) {
          return $s;
        }
        else {
          return $this->conn
            ->quote(strval($s));
        }
      }
    }
  }
}