Collections collection: insert (Array $ [, Array $ Options = Array ()])
Use of the second parameter of this method
'Safe ': Specifies a Boolean OR integer. The default value is false. If it is falseProgramWill continue, without waiting for the database response. That is, the program will not be interrupted no matter whether the data is successfully inserted.
'Fsync': The default value is false. If it is true, data is forcibly synchronized to the disk. The previous 'safe 'setting overwrites false.
PS: When I used MongoDB, I encountered a process that was inserted into the database, and another process could not read data immediately. It turns out that MongoDB may not insert data to the disk immediately.
'Timeout': Set the timeout value.
If the second parameter of this method is set to true only, the following is the case:
$ Mongo = new Mongo ("192.168.8.249: 27017 ");
$ Conn = $ mongo-> test-> Table1;
$ DATA = array (....);
$ Conn-> insert ($ data, true );
We set the safe parameter to true by default.
========================================================== ========================
About Indexes
<? PHP
$ Mongo = new Mongo ("192.168.8.249: 27017 ");
$ Conn = $ mongo-> test-> table;
$ Conn-> ensureindex (Array ("A" => 1, "B" => 1 ));
$ Award = array (
'A' => array (1 ),
'B' => array (2 ),
);
$ Conn-> insert ($ Award, true );
If we create a joint index, when inserting data, the two fields of the index are arrays, and the following error is returned.
"Cannot index parallel arrays"
Therefore, the fields of the joint index cannot be arrays.