Implemented blob support for SQLite. Allows null characters to be inserted into the...
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 6 Sep 2008 13:56:59 +0000 (13:56 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 6 Sep 2008 13:56:59 +0000 (13:56 +0000)
includes/db/DatabaseSqlite.php

index c6f9bc0..4ba0f1f 100644 (file)
@@ -289,15 +289,22 @@ class DatabaseSqlite extends Database {
        }
 
        function encodeBlob($b) {
-               return $this->strencode($b);
+               return new Blob( $b );
        }
 
        function decodeBlob($b) {
+               if ($b instanceof Blob) {
+                       $b = $b->fetch();
+               }
                return $b;
        }
 
        function addQuotes($s) {
-               return $this->mConn->quote($s);
+               if ( $s instanceof Blob ) {
+                       return "x'" . bin2hex( $s->fetch() ) . "'";
+               } else {
+                       return $this->mConn->quote($s);
+               }
        }
 
        function quote_ident($s) { return $s; }