AudioDidact\DB\MySQLDAL
Class MySQLDAL contains methods for communicating with a SQL database
Synopsis
class MySQLDAL
extends DAL
{
- // members
- protected string $userTable = "users";
- protected string $feedTable = "feed";
- protected array|string $myDBTables;
- protected array|array $correctSchemas;
- protected array $userCorrect = ;
- protected array $feedCorrect = ;
- // Inherited members from DAL
- protected static PDO $PDO;
- // methods
- public void __construct()
- public null|User getUserByID()
- private User setUser()
- public null|User getUserByWebID()
- public null|User getUserByUsername()
- public null|User getUserByEmail()
- public void addUser()
- public bool addVideo()
- public mixed updateVideo()
- public array|null getFeed()
- private Video setVideo()
- public mixed getFullFeedHistory()
- public bool setFeedText()
- public void updateUserPassword()
- public void updateUserEmailPasswordCodes()
- public void updateUser()
- public void makeDB()
- protected string makeColumnSQL()
- protected void updateDBSchema()
- protected array describeTable()
- protected string makeAlterQuery()
- public int verifyDB()
- protected array getDatabaseTables()
- private bool verifySchema()
- public array getPrunableVideos()
- // Inherited methods from DAL
- public abstract User getUserByID()
- public abstract mixed getFullFeedHistory()
- public abstract void addUser()
- public abstract mixed addVideo()
- public abstract mixed updateVideo()
- public abstract mixed setFeedText()
- public abstract void updateUser()
- public abstract void updateUserPassword()
- public abstract void updateUserEmailPasswordCodes()
- public bool inFeed()
- public abstract mixed getFeed()
- public bool usernameExists()
- public abstract User getUserByUsername()
- public bool webIDExists()
- public abstract User getUserByWebID()
- public bool emailExists()
- public abstract User getUserByEmail()
- public abstract mixed makeDB()
- public abstract mixed verifyDB()
- public abstract mixed getPrunableVideos()
Hierarchy
Extends
Coverage
Methods | 24% | 6 / 25 |
Lines | 79.88% | 258 / 323 |
Members
protected
- $PDO — \PDO
- $correctSchemas — AudioDidact\DB\array|array
- $feedCorrect
—
array
Correct layout of the feed table - $feedTable — string
- $myDBTables — AudioDidact\DB\array|string
- $userCorrect
—
array
Correct layout of the user table - $userTable — string
Methods
private
- setUser() — Makes a new user object from a database select command.
- setVideo() — Makes a new video object from a database select command.
- verifySchema() — Checks if two arrays are equal to test that SQL schemas are compliant
protected
- describeTable() — Function to get layout of a specific table
- getDatabaseTables() — Function to return a list of database tables
- makeAlterQuery() — Generates SQL query to add missing columns to the given tables
- makeColumnSQL() — Generates SQL query to make a column. Returns something in the form of `columnName` columnType NULL/Not Default Key Extra
- updateDBSchema()
public
- __construct() — MySQLDAL constructor.
- addUser() — Adds a User object to the database
- addVideo() — Adds a video to the feed table
- getFeed() — Returns an array of YouTube IDs that are in the feed
- getFullFeedHistory() — Gets all the videos from the database
- getPrunableVideos() — Returns an array of video IDs that can be safely deleted
- getUserByEmail() — Gets User from an email
- getUserByID() — Gets the user by the database user id
- getUserByUsername() — Gets a User from the database based on a username
- getUserByWebID() — Gets a User object from a webID
- makeDB() — Generate the tables in the current database
- setFeedText() — Sets full feed text in the feed database
- updateUser() — Updates the user database from a given \User object
- updateUserEmailPasswordCodes() — Updates only a user's email verification and password recovery codes in the database
- updateUserPassword() — Updates only a user's password in the database
- updateVideo() — Updates an existing video in the video database for a specific user
- verifyDB() — Verifies the currently connected database against the current schema
Inherited from AudioDidact\DB\DAL
public
- addUser() — Puts user into the database
- addVideo() — Adds video into the video database for a specific user
- emailExists() — Checks if an email is already in the database
- getFeed() — Gets all the videos from the database in the user's current feed limited by the max number of items the user has set
- getFullFeedHistory() — Gets all the videos from the database
- getPrunableVideos() — Returns an array of video IDs that can be safely deleted
- getUserByEmail() — Returns User class built from the database
- getUserByID() — Returns User class built from the database
- getUserByUsername() — Returns User class built from the database
- getUserByWebID() — Returns User class built from the database
- inFeed() — Default slow way to check if a video is in the feed. Override for faster lookup
- makeDB() — Sets up any database necessary
- setFeedText() — Sets feed xml text for a user
- updateUser() — Updates user entry in the database
- updateUserEmailPasswordCodes() — Updates only a user's email verification and password recovery codes in the database
- updateUserPassword() — Updates only a user's password in the database
- updateVideo() — Updates an existing video in the video database for a specific user
- usernameExists() — Checks if a username is taken in the database
- verifyDB() — Verifies the database
- webIDExists() — Checks if a webID is taken in the database