Reputation: 1954
I have just inherited a CI project and am trying to figure out some things. One of the problems I'm facing is the following:
Given these 2 links:
/esales/index.php/sales/send_receipt
/esales/index.php/sales/run
I was looking through the CI project and noted this file:
Inside esales/application/models/sale.php
, there were 2 functions that were executed, mainly:
class sale_model extends CI_Model{
public function get_sales_data(){ /* gets sales data */}
public function send_invoice(){ /* sends order receipt */}
And the idea is that when the user clicks /index.php/sales/run
, the function get_sales_data()
is run and when /index.php/sales/send_receipt
is clicked, send_invoice()
is run.
How does CodeIgniter connect the link to the native method in the model? In particular, how does CI know that /sales/
get translated to the sales_model
PHP object?
Upvotes: 0
Views: 80
Reputation: 38662
Model and View cannot be access without the command of controller. That's what we called MVC Security.
Your get_sales_data
and send_invoice
will not called automatcally/independantly unless your controller called it.
Check your controller you have these kind of code.
class Sales extends CI_Controller {
public function index() {
}
public function run()
{
$this->load->model('sale_model'); #load model
$this->sale_model->get_sales_data(); # access data
}
public function send_receipt()
{
$this->load->model('sale_model'); # load model
$this->sale_model->send_invoice(); # access data
}
}
Upvotes: 0
Reputation: 21
Have you checked the sales.php file in controller..which may contain "send_receipt", "run" methods. probably the model functions are called in those controller..
Upvotes: 2