09-27-2019, 08:24 PM
While I know the concept of MVC but I am not sure if I am doing this the most 'efficient' way
I have sql function in Model, I wan call it from Controller to pass it to View
Below is how I do the 'flow'.
Any shorter method or there a better way of doing?
Controller
Model
I have sql function in Model, I wan call it from Controller to pass it to View
Below is how I do the 'flow'.
Any shorter method or there a better way of doing?
Controller
PHP Code:
$participants = new ParticipantModel();
$data['participants_details'] = $participants ->participants_total();
echo view('login', $data);
Model
PHP Code:
<?php namespace App\Models;
use CodeIgniter\Model;
class ParticipantModel extends Model
{
public function participants_total() {
// (some sql query here and return result)
}
}