Word Lists Lemmata - warwickfoster/qurantools GitHub Wiki

File: app/library/database/login_logs_functions.php

Purpose

Functions for Database Calls to the LOGIN-LOGS Table

This section describes the functions responsible for interacting with the LOGIN-LOGS table in the database.

Functions

  • start_login_log($user_id): Starts a new login log entry for the given user ID.
  • end_login_log($login_log_id): Ends the login log entry with the given ID.
  • get_login_logs($user_id): Retrieves all login logs for the given user ID.

start_login_log($user_id)

  • Inserts a new row into the LOGIN-LOGS table with the following fields:
    • user_id (foreign key)
    • start_time (current timestamp)
    • end_time (null)

end_login_log($login_log_id)

  • Updates the row in the LOGIN-LOGS table with the given ID by setting the end_time field to the current timestamp.

get_login_logs($user_id)

  • Queries the LOGIN-LOGS table for all entries with the given user ID.
  • Returns an array of results, each containing the following fields:
    • login_log_id
    • user_id
    • start_time
    • end_time

Database Table Structure

Column Name Data Type Description
login_log_id INT Primary key
user_id INT Foreign key to the USERS table
start_time TIMESTAMP Timestamp of the start of the login session
end_time TIMESTAMP Timestamp of the end of the login session (nullable)

Usage

  • To start a new login log entry for a user, call the start_login_log() function with the user ID.
  • To end an existing login log entry, call the end_login_log() function with the login log ID.
  • To retrieve all login logs for a user, call the get_login_logs() function with the user ID.