โค๊ด ไฟล์ install ใน migrations
โค้ด: เลือกทั้งหมด
<?php namespace myproject\m_kaset\migrations;
class install_m_kaset extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
return isset($this->config['m_kaset_version']) && version_compare($this->config['m_kaset'], '1.0.0','>=');
}
static public function depends_on()
{
return array('\phpbb\db\migration\data\v310\dev');
}
public function update_schema()
{
return array
(
'add_tables' => array(
$this->table_prefix . 'm_plant' => array(
'COLUMNS' => array(
'plant_id' =>array('UINT:11',null,'auto_increment'),
'plant_name' =>array ('UINT:11',0),
'plant_characteristics' =>array ('UNIT:11',0),
'how_to' =>array('UNIT:11',0),
'age' =>array('UNIT:11',0),
'price'=>array('UNIT:11',0),
'properties'=>array('UNIT:11',0),
'user_add'=>array('UNIT:11',0),
'time_add'=>array('UNIT:11',0),
'user_edit'=>array('UNIT:11',0),
'time_edit'=>array('UNIT:11',0),
'detail'=>array('UNIT:11',0),
),
'PRIMARY_KEY' =>'plant_id',
),
),
);
}
public function revert_schema()
{
return array
(
'drop_tables' =>array(
$this->table_prefix . 'm_plant',
),
);
}
}
โค้ด: เลือกทั้งหมด
myproject_plant_controller:
path: /m_kaset/plant
defaults: { _controller: myproject.m_kaset.plant:plant}
requirements:
โค้ด: เลือกทั้งหมด
imports:
- { resource: tables.yml }
services:
myproject.m_kaset.plant:
class: myproject\m_kaset\controller\plant
arguments:
- @config
- @dbal.conn
- @request
- @template
- @user
- @controller.helper
- %core.root_path%
- %core.php_ext%
- %tables.m_plant%
หน้า tables.yml
โค้ด: เลือกทั้งหมด
parameters:
tables.m_plant: %core.table_prefix%m_plant
โค้ด: เลือกทั้งหมด
<?php
namespace myproject\m_kaset\controller;
class plant {
public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db,
\phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user,
\phpbb\controller\helper $helper, $root_path, $php_ext,$m_plant,$m_pest_has_plant,$m_pest,$m_fertilizer_has_plant,$m_fertilizer) {
$this->config = $config;
$this->db = $db;
$this->request = $request;
$this->template = $template;
$this->user = $user;
$this->helper = $helper;
$this->root_path = $root_path;
$this->php_ext = $php_ext;
$this->m_plant =$m_plant;
$this->m_pest_has_plant=$m_pest_has_plant;
$this->m_pest=$m_pest;
$this->m_fertilizer_has_plant=$m_fertilizer_has_plant;
$this->m_fertilizer=$m_fertilizer;
}
public function plant()
{
$page_title = $this->user->lang('plant');
$this->template->assign_block_vars('navlinks', array(
'FORUM_NAME' => $page_title,
'U_VIEW_FORUM' => $this->helper->route('myproject_m_kaset_controller', array ('name' =>'myproject')),
));
return $this->helper->render('plant.html', $this->user->lang('M_KASET'));
}
}
?>