Example #1
0
 /**
  * Takes an array representing a log and inserts it into the Logs table in the db
  * @static
  * @param array $logItem
  * @return int
  */
 private static function storeLog($logItem)
 {
     $db = Database::getInstance();
     $insert_log_stmt = $db->prepare('INSERT INTO Logs (user_id, type, line, file, message) VALUES (?, ?, ?, ?, ?)');
     $user_id = is_null(User::getLoggedUser()) ? 0 : User::getLoggedUser()->getId();
     $insert_log_stmt->bind_param('issss', $user_id, $logItem['type'], $logItem['line'], $logItem['file'], $logItem['message']);
     if ($insert_log_stmt->execute()) {
         return $db->insert_id;
     }
     return 0;
 }