Welcome Guest, Not a member yet? Register   Sign In
Call Model function from Controller
#1

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
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)
}

Reply


Messages In This Thread
Call Model function from Controller - by bustersg - 09-27-2019, 08:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB