Special case opus mime detction
[mediawiki.git] / includes / libs / rdbms / encasing / MssqlBlob.php
blob35be65c26e7c7c0d3d131b332493c15a831a3410
1 <?php
2 class MssqlBlob extends Blob {
3 public function __construct( $data ) {
4 if ( $data instanceof MssqlBlob ) {
5 return $data;
6 } elseif ( $data instanceof Blob ) {
7 $this->mData = $data->fetch();
8 } elseif ( is_array( $data ) && is_object( $data ) ) {
9 $this->mData = serialize( $data );
10 } else {
11 $this->mData = $data;
15 /**
16 * Returns an unquoted hex representation of a binary string
17 * for insertion into varbinary-type fields
18 * @return string
20 public function fetch() {
21 if ( $this->mData === null ) {
22 return 'null';
25 $ret = '0x';
26 $dataLength = strlen( $this->mData );
27 for ( $i = 0; $i < $dataLength; $i++ ) {
28 $ret .= bin2hex( pack( 'C', ord( $this->mData[$i] ) ) );
31 return $ret;