Crud operation in codeigniter 4 with Bootstrap 4

Creating the model in codeigniter 4

Creating the model in Codeigniter 4 is different from Codeigniter 3, in CodeIgniter 3 you always define the full body of the method but here in Codeigniter 4, you don’t need to define the whole function. Just configure the table with your Codeigniter 4 and pass some variables that’s it, now you are ready to go. In this lesson, you will learn how to create the model in Codeigniter 4.

<?php namespace App\Models;
use CodeIgniter\Model;

class MyStudents extends Model
{
  protected $DBGroup = 'default';

  protected $table = 'students';
  protected $primaryKey = 's_id';
  protected $returnType = 'array';
  protected $useTimestamps = true;
  protected $allowedFields = ['s_name','s_date','s_subject','s_update'];
  protected $createdField = 's_date';
  protected $updatedField = 's_update';

}

 

Featured Courses

Learn Web Development and web designing in few months from shakzee with real-world experience. Get up to 80% discount!