Class Table

Description

The Table class contains information about a table

Mainly used by the Database class.

Located in /phpfw.php (line 2781)


	
			
Variable Summary
array $columns
array $links
string $name
string $primary_key
string $type
Method Summary
Table Table (string $name, [ $external_name = ''], [ $primary_key = ''])
bool check_row_link (string $table,  $condition, string $link_ids, mixed $conditions)
mixed check_row_links (int $table_id, mixed $tables, mixed $conditions)
void delete_link_table_row (string $column_id, int $value)
void delete_table_row (int $table_id)
void delete_table_row_and_links (int $table_id)
void delete_table_row_and_link_rows (int $table_id)
void delete_table_row_links (int $table_id)
void delete_table_row_link_rows (int $table_id)
void &get_column_by_name (string $name)
string get_external_name ()
array &get_linked_to ()
string get_name ()
array get_table_row (int $table_id)
array get_table_rows ([string $options = ''])
array get_table_rows_with_actions ([string $view_action = 0], [string $update_action = 0], [string $del_action = 0], [string $options = ''], [string $params = ''], [mixed $ajax_element = ''])
void get_table_row_and_link_rows_for_view (int $table_id,  &$data, [bool $show_name = true], array $data)
void get_table_row_for_view (int $table_id,  &$data, [bool $show_name = true], array $data)
array get_table_row_links (int $table_id)
array get_table_row_links_with_actions (int $table_id, string $link_table_name, [string $view_action = 0], [string $update_action = 0], [string $del_action = 0], [string $options = ''], [string $params = ''], [mixed $ajax_element = ''])
void get_table_row_link_rows_for_view (int $table_id,  &$data, [bool $show_name = true], array $data)
string get_type ()
string process_sql_options (string $options, string $where)
void set_type (string $type)
Variables
array $columns (line 2799)
  • var:

    Associative array of Column objects

    $columns['column_name'] = Column object

string $external_name (line 2792)
  • var:

    External name of the table

    Uses ucwords() and replaces _ with spaces

array $links (line 2820)
  • var:

    Associative array of references to tables.

    $links['tablename'] = Table object reference

    • If data table, this array contains a list of link tables that link this table to another table.
    • If a link table, it contains a pair of data tables that the table links.

string $name (line 2785)
  • var: Name of the table
string $primary_key (line 2827)
  • var:

    Name of the primary key field. Default is {table_name}_id.

    This value can be modified using the table_id section in CONFIG_FILE.

string $type (line 2809)
  • var:

    Type of table - either 'data' or 'link'.

    • Data tables contain multiple columns and save data. They contain a primary key named tablename_id.
    • Link tables link two tables. They are named table1_table2 and contain two columns, table1_id and table2_id.

Methods
Constructor Table (line 2834)

Constructor for the Table class

Table Table (string $name, [ $external_name = ''], [ $primary_key = ''])
  • string $name: The name of the column
  • $external_name
  • $primary_key
check_row_link (line 3392)

Check that this table has the specified number of links with the specified tables

  • return: Returns a bool for success for failure
bool check_row_link (string $table,  $condition, string $link_ids, mixed $conditions)
  • string $table: Table name
  • mixed $conditions: String/Int specifying the condition - options are 1, 2, 3... for specific, '+' for 1 or more
  • string $link_ids: One or more colon separated IDs
  • $condition
check_row_links (line 3331)

Check that this table has the specified number of links with the specified tables

  • return: Returns a bool or an array of bools, one for each table specified in the same order
mixed check_row_links (int $table_id, mixed $tables, mixed $conditions)
  • int $table_id: ID of the row in this table to check links for
  • mixed $tables: String or array of strings of table names
  • mixed $conditions: String/Int or array of string/int specifying the condition - options are 1, 2, 3... for specific, '+' for 1 or more
delete_link_table_row (line 3420)

Delete a specific row from this table - for link tables

void delete_link_table_row (string $column_id, int $value)
  • string $column_id: Name of the column - should be name of the primary key of a data table
  • int $value: Value of the column - key of this data table
delete_table_row (line 3409)

Delete a specific row from this table - for data tables

void delete_table_row (int $table_id)
  • int $table_id: Primary key value for the row
delete_table_row_and_links (line 3476)

Delete a specific row and all links to other tables

void delete_table_row_and_links (int $table_id)
  • int $table_id: Primary key value for the row
delete_table_row_and_link_rows (line 3486)

Delete a specific row and all linked rows for this table

void delete_table_row_and_link_rows (int $table_id)
  • int $table_id: Primary key value for the row
delete_table_row_links (line 3430)

Delete all link table entries for the table id mentioned

void delete_table_row_links (int $table_id)
  • int $table_id: Primary key value of row in this table
delete_table_row_link_rows (line 3441)

Delete all links for a table - for data tables

void delete_table_row_link_rows (int $table_id)
  • int $table_id: Primary key value for the row
get_column_by_name (line 2898)

Get a column object by name

void &get_column_by_name (string $name)
  • string $name: Name of the column
get_external_name (line 2919)

Get the external table name

  • return: The external name string
string get_external_name ()
get_linked_to (line 2946)

Get the $links array

  • return: Returns the $links array
array &get_linked_to ()
get_name (line 2910)

Get the table name

  • return: The name string
string get_name ()
get_table_row (line 3146)

Get a specific row from this table

  • return: Returns an associative array with column names as key or empty array if no such result.
array get_table_row (int $table_id)
  • int $table_id: Primary key value for the row
get_table_rows (line 2957)

Get all the rows in this table

  • return: Returns an array of rows where each row is an associative array with column names as the key.
array get_table_rows ([string $options = ''])
  • string $options: Specify options to filter or order the results. (default: "")
get_table_rows_with_actions (line 3019)

Get all the rows in this table with the action field

If a Module:action is not specified, that action is not displayed. E.g. The update action is not displayed if $update_action is set to 0.

  • return: Returns an array of rows where each row is an associative array with column names as the key.
array get_table_rows_with_actions ([string $view_action = 0], [string $update_action = 0], [string $del_action = 0], [string $options = ''], [string $params = ''], [mixed $ajax_element = ''])
  • string $view_action: Action to execute when view button is clicked (Format: Module:action)
  • string $update_action: Action to execute when update button is clicked(Format: Module:action)
  • string $del_action: Action to execute when delete button is clicked(Format: Module:action)
  • string $options: Specify options to filter or order the results. (default: "")
  • string $params: Parameters required for the view, update and delete module:action combinations in "param=value&param=value" format. (default: "")
  • mixed $ajax_element: View, update and delete links will send their output to this element using AJAX if string specified. If array of strings then view[0], update[1], delete[2], (default: "")
get_table_row_and_link_rows_for_view (line 3291)

Get specific row and all linked rows from this table - formatted for View::table_two_column_associative()

This function appends the results of the query to $data. This is useful to generate $data using data from multiple tables and showing the result using View::table_two_column_associative().

void get_table_row_and_link_rows_for_view (int $table_id,  &$data, [bool $show_name = true], array $data)
  • int $table_id: Primary key value for the row
  • array $data: Return the data in this associative array
  • bool $show_name: Show the name of the table (default: true)
  • &$data
get_table_row_for_view (line 3172)

Get a specific row from this table - formatted for View::table_two_column_associative()

This function appends the results of the query to $data. This is useful to generate $data using data from multiple tables and showing the result using View::table_two_column_associative().

void get_table_row_for_view (int $table_id,  &$data, [bool $show_name = true], array $data)
  • int $table_id: Primary key value for the row
  • array $data: Return the data in this associative array
  • bool $show_name: Show the name of the table (default: true)
  • &$data
get_table_row_links (line 3212)

Get links to a table row.

This function checks the table's $links array and searches all its link tables for the specified ID. If it exists, it means that this row has a link with the other table.

Result = array( array(Table1 Object, Table2 Object, ...), array(Table1 ID1:Table1 ID2:Table1:ID3, Table2 ID, ...));

  • return: Returns an array of tables linked to and an array of IDs in that table.
array get_table_row_links (int $table_id)
  • int $table_id: Primary key value for the row
get_table_row_links_with_actions (line 3107)

Get all the link rows with the action field for the specified ID in this table

If a Module:action is not specified, that action is not displayed. E.g. The update action is not displayed if $update_action is set to 0.

  • return: Returns an array of rows where each row is an associative array with column names as the key.
array get_table_row_links_with_actions (int $table_id, string $link_table_name, [string $view_action = 0], [string $update_action = 0], [string $del_action = 0], [string $options = ''], [string $params = ''], [mixed $ajax_element = ''])
  • int $table_id: Primary key value for the row
  • string $link_table_name: Name of the table to which links need to be found
  • string $view_action: Action to execute when view button is clicked (Format: Module:action)
  • string $update_action: Action to execute when update button is clicked(Format: Module:action)
  • string $del_action: Action to execute when delete button is clicked(Format: Module:action)
  • string $options: Specify options to filter or order the results. (default: "")
  • string $params: Parameters required for the view, update and delete module:action combinations in "param=value&param=value" format. (default: 0)
  • mixed $ajax_element: View, update and delete links will send their output to this element using AJAX if string specified. If array of strings then view[0], update[1], delete[2], (default: "")
get_table_row_link_rows_for_view (line 3255)

Get all linked rows for a specific row from this table - formatted for View::table_two_column_associative()

This function appends the results of the query to $data. This is useful to generate $data using data from multiple tables and showing the result using View::table_two_column_associative().

void get_table_row_link_rows_for_view (int $table_id,  &$data, [bool $show_name = true], array $data)
  • int $table_id: Primary key value for the row
  • array $data: Return the data in this associative array
  • bool $show_name: Show the name of the table (default: true)
  • &$data
get_type (line 2928)

Get the table type

  • return: The type
string get_type ()
process_sql_options (line 3304)

Helper function to concatenate options to the SQL syntax, internal function, do not use

  • return: Returns the final options syntax
string process_sql_options (string $options, string $where)
  • string $options: Existing options
  • string $where: Additional where options to add
set_type (line 2937)

Set the table type

void set_type (string $type)
  • string $type: The type

Documentation generated on Sat, 23 Jun 2007 21:28:27 -0500 by phpDocumentor 1.3.2