use XoopsModules\Tadtools\TadDataCenter;
CREATE TABLE `模組名稱_data_center` (
`mid` mediumint(9) unsigned NOT NULL AUTO_INCREMENT COMMENT '模組編號',
`col_name` varchar(100) NOT NULL DEFAULT '' COMMENT '欄位名稱',
`col_sn` mediumint(9) unsigned NOT NULL DEFAULT '0' COMMENT '欄位編號',
`data_name` varchar(100) NOT NULL DEFAULT '' COMMENT '資料名稱',
`data_value` text NOT NULL COMMENT '儲存值',
`data_sort` mediumint(9) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`col_id` varchar(100) NOT NULL COMMENT '辨識字串',
`sort` mediumint(9) unsigned COMMENT '顯示順序',
`update_time` datetime NOT NULL COMMENT '更新時間',
PRIMARY KEY (
`mid`,
`col_name`,
`col_sn`,
`data_name`,
`data_sort`
)
) ENGINE = MyISAM DEFAULT CHARSET = utf8;
$TadDataCenter = new TadDataCenter($module_dirname);
$TadDataCenter->set_col($col_name, $col_sn);
$form = $TadDataCenter->getForm($mode, $form_tag, $name, $type, $value, $options, $attr, $sort);
$TadDataCenter = new TadDataCenter($module_dirname);
$TadDataCenter->set_col($col_name, $col_sn);
$TadDataCenter->assignBatchForm($form_tag, $data_arr = array(), $type = '', $attr = []);
$TadDataCenter = new TadDataCenter($module_dirname);
$TadDataCenter->set_col($col_name, $col_sn);
$TadDataCenter->saveData();
// 或
$data_arr = [
$data_name1 => [0 => $data_value1, 1 => $data_value2],
$data_name2 => [0 => $data_value3],
];
$TadDataCenter->saveCustomData($data_arr = []);
$TadDataCenter = new TadDataCenter($module_dirname);
$TadDataCenter->set_col($col_name, $col_sn);
$data = $TadDataCenter->getData($name, $sort = 0);
$xoopsTpl->assign('data', $data);
$data是二維陣列:$data['變數名稱1'][0]
、$data['變數名稱1'][1]
...
$TadDataCenter = new TadDataCenter($module_dirname);
$TadDataCenter->set_col($col_name, $col_sn);
$TadDataCenter->delData($name, $sort);
$TadDataCenter = new TadDataCenter($module_dirname);
$data = strToForm($setup = '');
$data 完整表單字串
$TadDataCenter = new TadDataCenter($module_dirname);
$data = getAllCols($setup);
$data是二維陣列
$TadDataCenter = new TadDataCenter($module_dirname);
$data = $TadDataCenter->getAllColItems($setup, $item = 'label');
$data是一維陣列,索引值是 label
$TadDataCenter = new TadDataCenter($module_dirname);
$data = $TadDataCenter->getColSetup($setup);
$data 是一維陣列,包括: