Php/codeigniter/model
提供: 初心者エンジニアの簡易メモ
application/models/Hello_model.php
<?php class Hello_model extends CI_Model { function __construct() { parent::__construct(); } function get_data() { $data = [ 'title' => 'hello!', 'message' => 'Helloworld!!' ]; return $data; } }
application/controller/Hello.php
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Hello extends CI_Controller { public function index() { $this->load->model('Hello_model'); $data = $this->Hello_model->get_data(); $this->load->view('hello', $data); } }