Class WPDP_List_Columns

Taken from WPDA_List_Columns. This class adds extra functionality for Data Projects. Column headers defined in 'Manage Table Options' are taken into account in this class.

author Peter Schulz
since 2.0.0
package WPDataProjects\Data_Dictionary
inherited_from \WPDataAccess\Data_Dictionary\WPDA_List_Columns

 Methods

WPDP_List_Columns constructor.

__construct(string $schema_name, string $table_name, string $label_type, string $setname = 'default'
inherited_from \WPDataAccess\Data_Dictionary\WPDA_List_Columns::__construct()

Parameters

$schema_name

string

Database schema name

$table_name

string

Database table name

$label_type

string

Label type

$setname

string

Options set name

WPDA_List_Columns constructor

__construct(string $schema_name, string $table_name) 
Inherited
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
Inherited
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
Inherited
since 2.7.2

Parameters

$column_name

Database column name

Returns

stringnull

Get column label (overwrites default method)

get_column_label(string $column_name) : string

Take column label from structure or default if not found (call parent method)

inherited_from \WPDataAccess\Data_Dictionary\WPDA_List_Columns::get_column_label()

Parameters

$column_name

string

Database column name

Returns

stringColumn label

Get column label for list table

get_column_label(string $column_name) : string
Inherited

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
Inherited
since 2.7.2

Parameters

$column_name

Database column name

Returns

stringnull

Get default column label

get_default_column_label(string $column_name) : string
Inherited

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.

Return options set name

get_setname() : string

Returns

string

get_table_alternative_keys()

get_table_alternative_keys() 
Inherited

Get column headers

get_table_column_headers() : array
Inherited
since 1.0.0

Returns

array

Get columns

get_table_columns() : array
Inherited
since 1.0.0

Returns

arrayColumn of $this->table_name.

Get primary key columns

get_table_primary_key() : array
Inherited
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
Inherited
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() 
Inherited

Set table column headers

set_table_column_headers() 

Use headers if a structure is found for the given table. Otherwise call parent to use the default.

inherited_from \WPDataAccess\Data_Dictionary\WPDA_List_Columns::set_table_column_headers()

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

set_table_column_headers() 
Inherited

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 (overwrites default method)

set_table_columns() 

Calls parent method to perform query and then sorts the result

inherited_from \WPDataAccess\Data_Dictionary\WPDA_List_Columns::set_table_columns()

Set table columns

set_table_columns() 
Inherited

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() 
Inherited

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

Gets the index of the column

get_array_index(string $column_options, string $column_name) : integer

Parameters

$column_options

string

Array containing columns and their options

$column_name

string

Database column name

Returns

integerColumn index

 Properties

 

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

$auto_increment_column_name : boolean | string

Default

false
 

Column options as define in Data Projects

$column_options : null | array

Default

null
 

Possible values: listtable and tableform

$label_type : \WPDataProjects\Data_Dictionary\label_type

Default

 

Database schema name

$schema_name : string

Default

 

Options set name

$setname : string

Default

'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