//举例查询 (userid,name,sex为user表的数据库字段) public function testa(){ $this->load->database(); $query = $this->db->query('SELECT * FROM user'); foreach ($query->result() as $row) { echo $row->userid;
01. 在Model中写数据库操作语句,代码如下: <?php namespace App\Models\System; use CodeIgniter\Model; class User_model extends Model { var $Db; function __construct() { parent::__construct(); //创建数据库连接 $this->Db = \Config\Database::connect(); } function deletedata()