MongoDB\BSON\Binary::__construct

(mongodb >=1.0.0)

MongoDB\BSON\Binary::__constructConstruit un nouveau binaire

Description

final public MongoDB\BSON\Binary::__construct ( string $data , int $type )

Liste de paramètres

data (string)

Les données binaires.

type (integer)

Entier 8 bits non signé indiquant le type de données.

Erreurs / Exceptions

Historique

Version Description
1.3.0

MongoDB\Driver\Exception\InvalidArgumentException est levée si type est MongoDB\BSON\Binary::TYPE_UUID ou MongoDB\BSON\Binary::TYPE_OLD_UUID et data n'a pas exactement 16 octets de longueur.

1.1.3

MongoDB\Driver\Exception\InvalidArgumentException est levée si type n'est pas un entier non signé de 8 bits.

Exemples

Exemple #1 Exemple avec MongoDB\BSON\Binary::__construct()

<?php

$binary 
= new MongoDB\BSON\Binary('foo'MongoDB\BSON\Binary::TYPE_GENERIC);
var_dump($binary);

?>

L'exemple ci-dessus va afficher :

object(MongoDB\BSON\Binary)#1 (2) {
  ["data"]=>
  string(3) "foo"
  ["type"]=>
  int(0)
}

Voir aussi