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