3-5-1
TadDataCenter 常用方法
您沒有觀看影片的權限
請先登入,登入後,確認您的權限後,即可觀看影片。
- 記得先use該物件:
use XoopsModules\Tadtools\TadDataCenter;
- 產生單一個表單欄位:
$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);