Package io.github.coho04.mysql.entities
Class Column
java.lang.Object
io.github.coho04.mysql.entities.Column
- All Implemented Interfaces:
QueryHelper
Represents a column in a database table.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.github.coho04.mysql.interfaces.QueryHelper
QueryHelper.ResultSetHandler<T>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
drop()
Drops the column from the table in the database.getAll()
Retrieves all search results from the database.boolean
getAsBoolean
(int id) Retrieves the boolean value of the specified column for a given ID.getAsString
(int id) Retrieves the string value of the specified column for a given ID.Retrieves the Database object associated with this Column.getName()
Retrieves the name of the column.Retrieves a random value from the specified column in the database table.getTable()
Retrieves the Table object associated with this Column.void
setItemNull
(int id) Sets the value of a specific item in the column to null.void
Sets the name of the column.void
setNull()
Sets the value of the column to null for all rows where the column is not already null.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.github.coho04.mysql.interfaces.QueryHelper
executeQuery, executeQuery, executeUpdate, executeUpdate
-
Constructor Details
-
Column
Initializes a new instance of the Column class with the given name, table, and MYSQL object.- Parameters:
name
- The name of the column.table
- The Table object associated with this column.mysql
- The MYSQL object used for database operations.
-
-
Method Details
-
getAll
Retrieves all search results from the database.- Returns:
- A SearchResults object containing all search results.
-
drop
public void drop()Drops the column from the table in the database. It executes an SQL query to alter the table and drop the specified column. -
getRandom
Retrieves a random value from the specified column in the database table.- Returns:
- The random value retrieved from the column.
-
setItemNull
public void setItemNull(int id) Sets the value of a specific item in the column to null.- Parameters:
id
- ID of the item to update.
-
setNull
public void setNull()Sets the value of the column to null for all rows where the column is not already null. This method updates the specified column in the table to null for all rows where the column is not already null. -
getAsBoolean
public boolean getAsBoolean(int id) Retrieves the boolean value of the specified column for a given ID.- Parameters:
id
- The ID of the column value to retrieve.- Returns:
- The boolean value of the column for the specified ID, or null if the ID does not exist or there is an error.
-
getAsString
Retrieves the string value of the specified column for a given ID.- Parameters:
id
- The ID of the column value to retrieve.- Returns:
- The string value of the column for the specified ID, or null if the ID does not exist or there is an error.
-
setName
Sets the name of the column.- Parameters:
name
- The new name for the column.
-
getDatabase
Retrieves the Database object associated with this Column.- Returns:
- The Database object associated with this Column.
-
getTable
Retrieves the Table object associated with this Column.- Returns:
- The Table object associated with this Column.
-
getName
Retrieves the name of the column.- Returns:
- The name of the column.
-