Example #1
0
 $set->timestamp = $gmtTime;
 $history = clone $set;
 //       $history->action      = 'update';
 //        $query->_id         = $postObject->glossarID;
 $addToSet = new stdClass();
 $addToSet = (object) array($history);
 $query = new stdClass();
 $query->{'$set'} = $set;
 $query->{'$addToSet'} = new stdClass();
 $query->{'$addToSet'}->history = $addToSet;
 // convert $query from stdObject to an arrayObject
 //            $query = stdObject_to_arrayObject($query);
 //var_dump($query);die;
 // database query
 //           $cursor = $collection->update($find,$query);
 $set = stdObject_to_arrayObject($set);
 //$find2 = stdObject_to_arrayObject($find2);
 //var_dump($query);die;
 $cursor2 = $collection->remove($find2);
 // var_dump($cursor2);
 if ($cursor2["ok"] == 1) {
     //echo "is weg";die;
     // database query
     $cursor = $collection->insert($set);
     // return result of database query
     if ($cursor["ok"] == 1) {
         $status = array("status" => array("code" => 200, "msg" => "success,update success"), "data" => "true");
         echo json_encode($status);
         die;
     } else {
         $status = array("status" => array("code" => 409, "msg" => "danger,update failed"), "data" => NULL);
Example #2
0
         $query->category = $postEntry->category;
         $query->title = $postEntry->title;
         $query->description = $postEntry->description;
         $query->lat = $postEntry->lat;
         $query->lon = $postEntry->lon;
         $query->name = $postEntry->name;
         $query->imageURL = $postEntry->imageURL;
         $query->email = $postEntry->email;
         $query->timestamp = $gmtTime;
         $history = clone $query;
         $history->action = 'create';
         //        $query->_id             = $postObject->glossarID;
         $query->history = new stdClass();
         $query->history = (object) array($history);
         // convert $query from stdObject to an arrayObject
         $query = stdObject_to_arrayObject($query);
         //var_dump($query);die;
         // database query
         $cursor = $collection->insert($query);
         // return result of database query
         if ($cursor["ok"] == 1) {
             $status = array("status" => array("code" => 200, "msg" => "success,insert success"), "data" => "true");
             echo json_encode($status);
             die;
         } else {
             $status = array("status" => array("code" => 409, "msg" => "danger,insert failed"), "data" => NULL);
             echo json_encode($status);
             die;
         }
     }
 } else {