Add Data
Public function Add () {
$this->data = [
[
' cust_id ' => ' 001 ',
' amount ' => M,
' status ' => ' A ',
' time ' => 1500134400
],
[
' cust_id ' => ' 001 ',
' amount ' => ,
' status ' => ' A ', ' Time
' => 1502726400
],
[
' cust_id ' => ' 002 ', '
amount ' => ,
' status ' => ' B ',
' time ' => 1504281600
],
];
$res = db::table (' document ')->insertall ($this->data);
if ($res) {
echo "success";
} else{
echo "error";
}
Results
Array (3) {
[0] => Array (5) {
[' _id '] => object (Mongodb\bson\objectid) #12 (1) {
[' oid '] => string (24 ) "5a51fffb83869e5bf002656b"
}
["cust_id"] => string (3) "001"
["Amount"] => int (m)
[status] ] => string (1) "A"
["Time"] => int (1500134400)
}
[1] => Array (5) {
["_id"] => object ( Mongodb\bson\objectid) #13 (1) {
["oid"] => string (a) "5a51fffb83869e5bf002656c"
}
["cust_id"] = > String (3) "001"
["Amount"] => int (a)
["Status"] => string (1) "A"
["Time"] => Int ( 1502726400)
}
[2] => Array (5) {
["_id"] => object (Mongodb\bson\objectid) #14 (1) {
[' oid '] = > string "5a51fffb83869e5bf002656d"
}
["cust_id"] => string (3) "002"
["Amount"] => int (10 )
[' Status '] => string (1) "B"
["Time"] => int (1504281600)
}
}
query by time period
Public Function Select_by_time () {
//$map [' time '] = [' Between ', ' 1500134399 ', ' 1502726401 '];
$map [' time '] = array (' Between ', [' 1500134399 ', ' 1502726401 ']);
$res = db::table (' document ')->where ($map)->select ();
Dump ($res);
Results
Array (2) {
[0] => Array (5) {
[' _id '] => object (Mongodb\bson\objectid) #12 (1) {
[' oid '] => string (24 ) "5a52011083869e4b674156fa"
}
["cust_id"] => string (3) "001"
["Amount"] => int (m)
[ Status "] => string (1)" A "
[" Time "] => string (Ten)" 1500134400 "
}
[1] => Array (5) {
[" _id "] = > Object (Mongodb\bson\objectid) #13 (1) {
[' oid '] => string (in) ' 5A52011083869E4B674156FB '
}
[ cust_id "] => string (3)" 001 "
[" Amount "] => int ()
[" Status "] => string (1)" A "
[" Time "] => String (Ten) "1502726400"
}
}