Merge "jquery.suggestions: Correctly place dropdown for inputs with 'position: fixed'"
[lhc/web/wiklou.git] / includes / libs / rdbms / encasing / MssqlBlob.php
1 <?php
2
3 namespace Wikimedia\Rdbms;
4
5 class MssqlBlob extends Blob {
6 /** @noinspection PhpMissingParentConstructorInspection */
7
8 /**
9 * @param Blob|string $data
10 */
11 public function __construct( $data ) {
12 if ( $data instanceof MssqlBlob ) {
13 $this->data = $data->data;
14 } elseif ( $data instanceof Blob ) {
15 $this->data = $data->fetch();
16 } else {
17 $this->data = $data;
18 }
19 }
20
21 /**
22 * Returns an unquoted hex representation of a binary string
23 * for insertion into varbinary-type fields
24 * @return string
25 */
26 public function fetch() {
27 if ( $this->data === null ) {
28 return 'null';
29 }
30
31 $ret = '0x';
32 $dataLength = strlen( $this->data );
33 for ( $i = 0; $i < $dataLength; $i++ ) {
34 $ret .= bin2hex( pack( 'C', ord( $this->data[$i] ) ) );
35 }
36
37 return $ret;
38 }
39 }