Merge "Don't fallback from uk to ru"
[lhc/web/wiklou.git] / includes / libs / rdbms / encasing / MssqlBlob.php
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;
12 }
13 }
14
15 /**
16 * Returns an unquoted hex representation of a binary string
17 * for insertion into varbinary-type fields
18 * @return string
19 */
20 public function fetch() {
21 if ( $this->mData === null ) {
22 return 'null';
23 }
24
25 $ret = '0x';
26 $dataLength = strlen( $this->mData );
27 for ( $i = 0; $i < $dataLength; $i++ ) {
28 $ret .= bin2hex( pack( 'C', ord( $this->mData[$i] ) ) );
29 }
30
31 return $ret;
32 }
33 }