โค้ด: เลือกทั้งหมด
public function plant($action) {
switch ($action) {
case 'show_all':
$this->show_data_all();
$this->template->assign_vars(array(
'SHOW_ALL' => true,
'A_ACTION' => $this->helper->route('myproject_controller', array('action' => 'add_data'))
));
break;
case 'add_data':
$data = array(
'plant_id' => $this->request->variable('plant_id', ''),
'plant_name ' => $this->request->variable('plant_name', '', true),
);
$this->insert($data);
$this->template->assign_vars(array(
'SHOW_FORM_ADD' => true,
));
break;
default:
break;
}
return $this->helper->render('plant.html', $this->user->lang('M_KASET'));
}
public function insert($data) {
$sql = 'INSERT INTO ' . $this->m_plant . '' . $this->db->sql_build_array('INSERT', $data);
$this->db->sql_query($sql);
}
public function show_data_all() {
$per_page = $this->request->variable('this', $this->config ['topics_per_page']);
$start = $this->request->variable('stat', 0);
$sql = ' SELECT *
FROM ' . $this->m_plant;
$result = $this->db->sql_query_limit($sql, $per_page, $start);
while ($row = $this->db->sql_fetchrow($result)) {
$this->template->assign_block_vars('plant', array(
'PLANT_ID' => $row['plant_id'],
'PLANT_NAME' => $row['plant_name'],
));
}
}