小编Gre*_*dom的帖子

我可以对多个表使用单个 CodeIgniter 模型吗?

我有一个包含多个表的体育赛事的数据库。一些表保存结果的记录,有一个用户配置文件表,以及一些杂项表。

我的模型如下:

class Results extends CI_Model
{
    public function __construct()
    {
        parent::__construct();
    }

    public function displayrecords($table) {
        $query=$this->db->query("select * from " . $table);
        return $query->result();
    }

    public function getdisplayname($table) {
        $query=$this->db->query("select * from " . $table);
        return $query->result();
    }

    public function updatetable() {

    }

    public function deleterecords($table, $id) {
        $this->db->query("delete * from " . $table . " where id='" . $id . "'");
    }
}
Run Code Online (Sandbox Code Playgroud)

以及索引视图的控制器:

public function index() {
    // Load the models
    $this->load->model('Results');
    $this->load->model('Info');
    $this->load->model('TableNames');

    // Create the …
Run Code Online (Sandbox Code Playgroud)

php codeigniter

5
推荐指数
1
解决办法
1815
查看次数

标签 统计

codeigniter ×1

php ×1