Författare:
Per Stenebo
Skapad:
2012-01-05 05:57:39
Ändrad:
2017-04-16 12:59:26
sv

Hantera tabelldata

Detta är ett generellt skript för att visa, söka och redigera data i en databas.
Det ingår inte i en standardinstallation av BendCMS.

Funktionsbeskrivning

Skriptet startar med en konfigurationsfil med ett liknande namn som den primära tabellen som skall hanteras.
Konfigurationsfilen innehåller inställningar för vilken data som skall hämtas och hur skriptet skall visa, behandla och validera datan.

Konfigurationsfilen läggs in som sidans logikfil.

I sidstacken läggs sidan tabelldata in precis efter huvudsidan.

Konfigurationsfil

Tabell

$table = 'tblItem'; Table name

$p_k = 'id'; Primary key

$orderby = 'Itemnr, Name'; Set columns to sort on

$sort = 'ASC'; Set sort order like ASC or DESC

$limit = 10; Number of rows to show in table

Knappar

$copy = true; Enable copy button in edit mode. Defaults to false.

$delete = true; Enable delete button in edit mode. Defaults to false.

Inkludera filer

// Array of include file paths. Defaults to empty arrays.

$code_do_action = array('global/inc/aFile.php', 'global/inc/anotherFile.php'); 

$code_table_cell = array('global/inc/item-links_cell.php');

$code_fieldset = array('global/inc/connect_fieldset.php');

$code_navigate = array('global/inc/item-links_navigate.php');

$code_table_header = array('global/inc/connect_header.php');

$code_table_filter = array('global/inc/connect_filter.php');

$code_table_row = array('global/inc/connect_row.php');

Konfigurera tabell

Skapa en flerdimensionell array för att beskriva tabellen i databasen och konfigurera hur skriptet skall visa, behandla och validera datan.

Define all columns that should be updated or shown

$table_config[$table]['id'] = array( Define column in primary table

'col-lang'=>'ID', // Set common name for this column to use in labels, headers and messages.

'filter-type'=>'text', // FALSE/text/select/multiple/checkbox | Set type of filter box. Hidden if FALSE.

'filter-style'=>FALSE, // FALSE/''/'css-rule' | Set specific css style rules for filter box between headers and data table, like 'width:100px;'. Hidden if FALSE.

'filter-title'=>'', // Optional | Set custom title text for filter field.

'table-style'=>FALSE, // FALSE/''/'css-rule' | Set specific css style rules for cell in data table, like 'text-align:right;'. Hidden if FALSE.

'table-title'=>'', // Set title text for this column in data table

'table-translate'=>false | TRUE/FALSE/'input-option-arr' | Optional, defaults to TRUE. 
TRUE = Show foreign value instead of foreign key. 
FALSE = Show value from primary table (foreign key).
 'input-option-arr' = Pull values from options array instead of foreign table.

'table-encode'=>false TRUE = Encode content with htmlspecialchars(). Optional, defaults to TRUE. | TRUE/FALSE | 

'input-type'=>FALSE, // FALSE/text/textarea/select/multiple/checkbox | Set type of input box. Hidden if FALSE.

'input-option-arr'=>array(), // Must be set and contain options if 'input-type' is 'multiple'. Optional if 'input-type' is 'select'.

'input-option-db'=>TRUE, // Optional | Input-options for SELECT box are not fetched from db if FALSE. Defaults to TRUE.

'input-style'=>'', // Set specific css style rules for input box, like 'text-align:right; width:50px;'

'input-title'=>'', // Set title for input box

'validate-min'=>1, // Set min input string length. No input are required if 0 (zero)

'validate-max'=>5, // Set max string length. 'max' also gives value for maxlength property (only on text box)

'validate-type'=>'num', // 0_1 num/num_dot/num_let/name/word/text/email/date/datetime | Set type of data to validate input with.

't-alias'=>'a', // a/b/c/d/.. | Set table alias. a is always primary table. All variables and box names will be prefixed with this alias to avoid ambiguous names. 'id' becomes 'aid'.

'f-t-n'=>FALSE, // Name of foreign table, only appliccable on foreign keys, set to FALSE otherwise.

'f-t-k'=>FALSE, // Name of key column in foreign table, only appliccable on foreign keys, set to FALSE otherwise.

'f-t-v'=>FALSE // Name of value column in foreign table, only appliccable on foreign keys, set to FALSE otherwise.

);

 

 

Kommentarer till sidan Tabelldata