라이브러리

[PHP] MongoDBBSONBinaryInterface::getType - BinaryInterface의 유형을 반환합니다.




MongoDBBSONBinaryInterface::getType

`MongoDBBSONBinaryInterface`는 MongoDB의 BSON(Binary Serialized Object Notation) 형식의 데이터를 다루는 인터페이스입니다. 이 인터페이스에는 `getType()` 메소드가 포함되어 있습니다. 이 메소드는 BSON 데이터의 유형을 반환합니다.

getType() 메소드

`getType()` 메소드는 BSON 데이터의 유형을 반환하는 메소드입니다. 이 메소드는 다음 유형의 데이터를 반환할 수 있습니다.

* `int`: 정수
* `string`: 문자열
* `double`: 실수
* `null`: null
* `bool`: 논리값 (true/false)
* `array`: 배열
* `object`: 객체
* `date`: 날짜
* `binary`: 이진 데이터
* `oid`: ObjectId (ObjectId는 MongoDB에서 사용하는 고유한 아이디)
* `code`: 코드 (함수나 프로시저)
* `codeWScope`: 코드와 스코프 (함수나 프로시저와 스코프)
* `document`: 문서 (MongoDB에서 사용하는 문서)
* `maxKey`: 최대 키
* `minKey`: 최소 키
* `regex`: 정규표현식
* `DBRef`: DBRef (MongoDB에서 사용하는 DBRef)

예제

다음 예제는 `getType()` 메소드를 사용하여 BSON 데이터의 유형을 반환하는 방법을 보여줍니다.

#hostingforum.kr
php

use MongoDBBSONBinary;

use MongoDBBSONUTCDateTime;



// 정수

$int = 123;

echo $int->getType() . "
"; // int



// 문자열

$string = "hello";

echo $string->getType() . "
"; // string



// 실수

$double = 123.456;

echo $double->getType() . "
"; // double



// null

$null = null;

echo $null->getType() . "
"; // null



// 논리값

$bool = true;

echo $bool->getType() . "
"; // bool



// 배열

$array = ["a" => 1, "b" => 2];

echo $array->getType() . "
"; // array



// 객체

$obj = new stdClass();

$obj->a = 1;

$obj->b = 2;

echo $obj->getType() . "
"; // object



// 날짜

$date = new UTCDateTime();

echo $date->getType() . "
"; // date



// 이진 데이터

$binary = new Binary("hello", Binary::TYPE_STRING);

echo $binary->getType() . "
"; // binary



// ObjectId

$oid = new MongoDBBSONObjectId();

echo $oid->getType() . "
"; // oid



// 코드

$code = new MongoDBBSONCode("function() { console.log('hello'); }");

echo $code->getType() . "
"; // code



// 코드와 스코프

$codeWScope = new MongoDBBSONCodeWScope("function() { console.log('hello'); }", ["scope" => "hello"]);

echo $codeWScope->getType() . "
"; // codeWScope



// 문서

$document = new MongoDBBSONDocument();

echo $document->getType() . "
"; // document



// 최대 키

$maxKey = MongoDBBSONMaxKey::create();

echo $maxKey->getType() . "
"; // maxKey



// 최소 키

$minKey = MongoDBBSONMinKey::create();

echo $minKey->getType() . "
"; // minKey



// 정규표현식

$regex = new MongoDBBSONRegex("/hello/");

echo $regex->getType() . "
"; // regex



// DBRef

$dbRef = new MongoDBBSONDBRef("collection", "document");

echo $dbRef->getType() . "
"; // DBRef



이 예제는 `getType()` 메소드를 사용하여 BSON 데이터의 유형을 반환하는 방법을 보여줍니다. 각 유형의 데이터를 생성하고 `getType()` 메소드를 호출하여 유형을 반환합니다.
  • profile_image
    나우호스팅 @pcs8404 

    호스팅포럼 화이팅!

    댓글목록

    등록된 댓글이 없습니다.

  • 전체 10,077건 / 409 페이지

검색

게시물 검색