/** * @param string|Blob $s * @return string */ public function addQuotes($s) { if ($s instanceof MssqlBlob) { return $s->fetch(); } elseif ($s instanceof Blob) { // this shouldn't really ever be called, but it's here if needed // (and will quite possibly make the SQL error out) $blob = new MssqlBlob($s->fetch()); return $blob->fetch(); } else { if (is_bool($s)) { $s = $s ? 1 : 0; } return parent::addQuotes($s); } }
/** * @param Blob|string $s * @return string */ function addQuotes($s) { if ($s instanceof Blob) { return "x'" . bin2hex($s->fetch()) . "'"; } elseif (is_bool($s)) { return (int) $s; } elseif (strpos($s, "") !== false) { // SQLite doesn't support \0 in strings, so use the hex representation as a workaround. // This is a known limitation of SQLite's mprintf function which PDO should work around, // but doesn't. I have reported this to php.net as bug #63419: // https://bugs.php.net/bug.php?id=63419 // There was already a similar report for SQLite3::escapeString, bug #62361: // https://bugs.php.net/bug.php?id=62361 // There is an additional bug regarding sorting this data after insert // on older versions of sqlite shipped with ubuntu 12.04 // https://bugzilla.wikimedia.org/show_bug.cgi?id=72367 wfDebugLog(__CLASS__, __FUNCTION__ . ': Quoting value containing null byte. For consistency all binary data should have been first processed with self::encodeBlob()'); return "x'" . bin2hex($s) . "'"; } else { return $this->mConn->quote($s); } }
/** * @param Blob|string $s * @return string */ function addQuotes($s) { if ($s instanceof Blob) { return "x'" . bin2hex($s->fetch()) . "'"; } elseif (is_bool($s)) { return (int) $s; } elseif (strpos($s, "") !== false) { // SQLite doesn't support \0 in strings, so use the hex representation as a workaround. // This is a known limitation of SQLite's mprintf function which PDO should work around, // but doesn't. I have reported this to php.net as bug #63419: // https://bugs.php.net/bug.php?id=63419 // There was already a similar report for SQLite3::escapeString, bug #62361: // https://bugs.php.net/bug.php?id=62361 return "x'" . bin2hex($s) . "'"; } else { return $this->mConn->quote($s); } }