Example #1
0
 /**
  * 
  * @param be_vse_data $entry Datagram containing all data to be registered.
  * @return \be_vse_data value inserted
  */
 public static function AddEntry($entry)
 {
     $sqlCommand = "INSERT INTO vse_data (app_id,vse_label, vse_value, vse_type, vse_annotations,captured_datetime)" . " VALUES (?,?,?,?,?,?)";
     $paramTypeSpec = "isssss";
     $mysqli = DA_Helper::mysqli_connect();
     if ($mysqli->connect_errno) {
         $msg = "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
         throw new Exception($msg, $mysqli->connect_errno);
     }
     if (!($stmt = $mysqli->prepare($sqlCommand))) {
         $msg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
         throw new Exception($msg, $stmt->errno);
     }
     if (!$stmt->bind_param($paramTypeSpec, $entry->app_id, $entry->vse_label, $entry->vse_value, $entry->vse_type, $entry->vse_annotations, $entry->captured_datetime)) {
         $msg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
         throw new Exception($msg, $stmt->errno);
     }
     if (!$stmt->execute()) {
         $msg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
         throw new Exception($msg, $stmt->errno);
     }
     $stmt->close();
     $insertedEntryID = $mysqli->insert_id;
     $insertedEntry = da_vse_data::getSpecificEntry($insertedEntryID);
     return $insertedEntry;
 }