3 namespace Wikimedia\Rdbms
;
5 class MssqlBlob
extends Blob
{
6 /** @noinspection PhpMissingParentConstructorInspection */
10 * @suppress PhanTypeMagicVoidWithReturn
12 public function __construct( $data ) {
13 if ( $data instanceof MssqlBlob
) {
15 } elseif ( $data instanceof Blob
) {
16 $this->data
= $data->fetch();
17 } elseif ( is_array( $data ) && is_object( $data ) ) {
18 $this->data
= serialize( $data );
25 * Returns an unquoted hex representation of a binary string
26 * for insertion into varbinary-type fields
29 public function fetch() {
30 if ( $this->data
=== null ) {
35 $dataLength = strlen( $this->data
);
36 for ( $i = 0; $i < $dataLength; $i++
) {
37 $ret .= bin2hex( pack( 'C', ord( $this->data
[$i] ) ) );