我有一个包含多个表的体育赛事的数据库。一些表保存结果的记录,有一个用户配置文件表,以及一些杂项表。
我的模型如下:
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)