定義
MongoDB\GridFS\Bucket::__construct()新しい
Bucketインスタンスを構築します。function __construct( MongoDB\Driver\Manager $manager, string $databaseName, array $options = [] )
パラメーター
$manager: MongoDB\Driver\Manager- 拡張機能からの マネージャーインスタンス。マネージャーはドライバーとMongoDBの間の接続を維持します。
$databaseName: string- データベースの名前。
$options: 配列必要なオプションを指定する配列。
名前タイプ説明bucketName
string
ファイルとチャンク コレクションのプレフィックスとして使用されるバケット名。 デフォルトは
"fs"です。chunkSizeBytes
integer
バイト単位での チャンク サイズ 。 デフォルトは
261120( 255 キー B)。コーデック
MongoDB\Codec\DocumentCodec
タイプ コーデックでデータをエンコードするデフォルトのエンコード メソッドは、ファイルドキュメントを返すバケットメソッド(例:
MongoDB\GridFS\Bucket::find())。バージョン1.17の新機能。
disableMD5
ブール値
ファイルを保存するときに MD5 の自動生成を無効にするかどうか。
デフォルトは
falseです。 2.0ではtrueのみがサポートされます。バージョン1.4の新機能。
ReadConcern
バケット操作に使用するデフォルトの読み取り保証 (read concern) です。 デフォルトは、マネージャーの読み取り保証 (read concern) です。
readPreference
バケット操作に使用するデフォルトの読み込み設定 (read preference) 。 デフォルトは、マネージャーの読み込み設定 (read preference) です。
typeMap
配列
Default type map to apply to cursors, which determines how BSON documents are converted to PHP values. The library uses the following type map by default:
[ 'array' => 'MongoDB\Model\BSONArray', 'document' => 'MongoDB\Model\BSONDocument', 'root' => 'MongoDB\Model\BSONDocument', ] writeConcern
バケット操作に使用するデフォルトの書込み保証 (write concern) です。 デフォルトは、マネージャーの書込み保証 (write concern) です。
エラーと例外
MongoDB\Exception\InvalidArgumentException は、パラメータまたはオプションの解析に関連するエラーの場合は です。
動作
If you construct a Bucket explicitly, the Bucket inherits any options from the MongoDB\Driver\Manager object. If you select the Bucket from a Database object, the Bucket inherits its options from that object.
例
$bucket = (new MongoDB\Client)->test->selectGridFSBucket(); var_dump($bucket);
出力は次のようになります。
object(MongoDB\GridFS\Bucket)#3053 (2) { ["bucketName"]=> string(4) "test" ["databaseName"]=> string(11) "phplib_test" }