Create controller
Path:/controllers/demo.php
- class Demo extends IController
- {
- public $layout = 'site';
-
- function init()
- {
- CheckRights::checkUserRights();
- }
-
- / **
- *Default index method
- */
- public function index()
- {
- // Call Model
- // Demo_Class::show();
-
- // Get Admin table list information
- $adminRow = Demo_Class::adminList();
-
- // Get Admin form information
- $adminInfo = Demo_Class::adminInfo();
-
- // Error jump
- // IError::show(404,'Payment interface class not found');
-
- // Jump to template
- $this->redirect('index');
- }
-
- /**
- * Test method controller
- */
- public function demo_list()
- {
- echo 'demo';
- exit;
- }
- }
Copy code
Title text
Path: /classes/demo_class.php
- class Demo_Class
- {
- /**
- * Get data table information output
- */
- public function adminList()
- {
- // Get the user table list
- $adminObj = new IModel(' user');
- $adminRow = $adminObj->query();
- return $adminRow;
- }
-
-
- /**
- * Get data table information output
- */
- public function adminInfo()
- {
- // Get admin table user List
- $adminObj = new IModel('admin');
- $adminRow = $adminObj->getObj('admin_name = "admin"');
- return $adminRow;
- }
-
-
- /**
- *Normal output
- * /
- public static function show()
- {
- echo 'Who am I';
- }
-
- }
Copy code
Create view
Path:/views/default/demo/index.html
- Output ordinary model: {echo:Demo_Class::show();}
-
-
- Output array: {set:$arrInfo = Demo_Class::adminInfo(); echo $arrInfo['last_ip' ];}
-
-
- {foreach:items = Demo_Class::adminList()}
- {$item[' username']}
- {/foreach}
Copy code
|