Class Column

java.lang.Object
io.github.coho04.mysql.entities.Column
All Implemented Interfaces:
QueryHelper

public class Column extends Object implements QueryHelper
Represents a column in a database table.
  • Constructor Details

    • Column

      public Column(String name, Table table, MYSQL mysql)
      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

      public SearchResults 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

      public Object 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

      public String getAsString(int id)
      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

      public void setName(String name)
      Sets the name of the column.
      Parameters:
      name - The new name for the column.
    • getDatabase

      public Database getDatabase()
      Retrieves the Database object associated with this Column.
      Returns:
      The Database object associated with this Column.
    • getTable

      public Table getTable()
      Retrieves the Table object associated with this Column.
      Returns:
      The Table object associated with this Column.
    • getName

      public String getName()
      Retrieves the name of the column.
      Returns:
      The name of the column.