Welcome Guest, Not a member yet? Register   Sign In
How query generates in controller,, without any function call to loaded Model ?
#1

Hello, Hi to all

i am some novice ,

i have FusionInvoice from Github, i am unable to understand, how its controller is getting query result from model, where the function not exist in model.

in its Quotes/Create Quote Modal,  Client Name filed has .TypeAhed plugin,

Client Name : $.post("<?php echo site_url('clients/ajax/name_query'); ?>"

The Clients/Ajax Controller has function


PHP Code:
 public function name_query()
    {
        // Load the model
        $this->load->model('clients/mdl_clients');

        // Get the post input
        $query $this->input->post('query');

        $clients $this->mdl_clients->select('client_name')->like('client_name'$query)->order_by('client_name')->get(array(), FALSE)->result();

        $response = array();

        foreach ($clients as $client)
        {
            $response[] = $client->client_name;
        }

        echo json_encode($response);
    

But the mdl_clients  has no "select" function defined,, 
but yes , there is a function called  "default_select",  but its totally different than the one passed as in above controller to $clients.

the default_select in mdl_cleints is as following
 
PHP Code:
public function default_select()
    {
        $this->db->select('SQL_CALC_FOUND_ROWS fi_client_custom.*, fi_clients.*'FALSE);
    

Can any one help please how controller is getting query data ?  As in controller,, only field name is given in query, without table name,, so how its doing then ?

Any help will be appericiated
Thanks
Reply
#2

Is the model mdl_clients a child class of some other model and not CI_Model? Is it, for example, defined something like this?

PHP Code:
class Mdl_clients extends Some_other_model 

If true, then the select method is probably in Some_other_model
Reply
#3

Yes, you are right,
mdl_client is child of My_Model

i hv attached the my_model file

i think it using __callget and set_defaults functions.



Attached Files
.php   MY_Model.php (Size: 11.04 KB / Downloads: 55)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB