Class WPDA_List_Columns

author Peter Schulz
since 1.0.0
package WPDataAccess\Data_Dictionary

 Methods

WPDA_List_Columns constructor

__construct(string $schema_name, string $table_name) 
since 1.0.0

Parameters

$schema_name

string

Database schema name.

$table_name

string

Database table name.

Get name of auto increment column

get_auto_increment_column_name() : boolean | string
since 1.0.0

Returns

booleanstringName of auto increment column or false if no auto increment column exists

Return column data type

get_column_data_type($column_name) : string | null
since 2.7.2

Parameters

$column_name

Database column name

Returns

stringnull

Get column label for list table

get_column_label(string $column_name) : string

Returns the label of a column according to a pre defined format. Call must contain column name. Column must be in $this->table_name.

since 1.0.0

Parameters

$column_name

string

Column name as defined in the data dictionary.

Returns

stringLabel for $column_name.

Return column type

get_column_type($column_name) : string | null
since 2.7.2

Parameters

$column_name

Database column name

Returns

stringnull

Get default column label

get_default_column_label(string $column_name) : string

Returns the default label of a column according to a pre defined format. Call must contain column name. Column must be in $this->table_name.

since 1.0.0

Parameters

$column_name

string

Column name as defined in the data dictionary.

Returns

stringDefault label for $column_name.

get_table_alternative_keys()

get_table_alternative_keys() 

Get column headers

get_table_column_headers() : array
since 1.0.0

Returns

array

Get columns

get_table_columns() : array
since 1.0.0

Returns

arrayColumn of $this->table_name.

Get primary key columns

get_table_primary_key() : array
since 1.0.0

Returns

arrayPrimary key columns of $this->table_name.

Check if column is part of primary key

is_primary_key_column(string $column_name) : boolean
since 1.0.0

Parameters

$column_name

string

Column name as defined in the data dictionary.

Returns

booleanTRUE = column is part of primary key, FALSE = column is not part of primary key.

get_table_unique_indexes()

get_table_unique_indexes() 

Set column headers (= column labels in data entry forms)

set_table_column_headers() 

For now column headers are defined equal to their names. If a column is part of the primary key, this is reflected in the column header.

since 1.0.0

Set table columns

set_table_columns() 

Column info is taken from the MySQL data dictionary. For each column in $this->table_name the following column info is stored:

  • Column name
  • Data type (MySQL data type)
  • Extra (needed to find auto increment columns)
  • Column type (needed for columns with data type enum: column type holds allowed values)
  • Null values allowed?

Since MariaDB 10.2.7 and higher handles default values different than other DBMSs we have to take care of the quotes it places at the beginning and the end. This involves the implication that users cannot use default values that start and end with a single quote. Which seems common sense for me.

since 1.0.0

Set primary key columns

set_table_primary_key() 

Primary key columns are taken from the MySQL data dictionary.

Newer versions of MariaDB no longer seem to support JOIN USING. Rewritten to old school join. MySQL supports both types of joins.

since 1.0.0

 Properties

 

Auto increment column name of $this->table_name or false

$auto_increment_column_name : boolean | string

Default

false
 

Database schema name

$schema_name : string

Default

 

Column data type sorted on column name

$table_column_data_type : array

Default

array()
 

Column headers for $this->table_name

$table_column_headers : array

Default

array()
 

Column type sorted on column name

$table_column_type : array

Default

array()
 

Columns of $this->table_name

$table_columns : array

Default

array()
 

Database table name

$table_name : string

Default

 

Primary key columns of $this->table_name

$table_primary_key : array

Default

array()
 

Primary key columns of $this->table_name (named)

$table_primary_key_check : array

Default

array()
 

Table settings as define in Data Explorer

$table_settings : null | Object

Default

null
 

Database connection

$wpdadb : null

Default

null