Welcome Guest, Not a member yet? Register   Sign In
codeigniter 3 where clause does not work properly
#1
Wink 

Hey @all
I am using CodeIgniter version 3, I face an error of querying a table that have large amount of data while I passed it where condition but my model escaped where and changed it to where variable is null after I dumped into last_query
here is my code 
view code
Code:
<?php echo form_open('Access/show'); ?>
                        <div class="form-group">
                            <div class="my-3">
                                <label class="form-label" for="startdate">Dooro Taariikh:</label>
                                <input type="date" class="form-control" value="" name="whichday" id="whichday" required="required">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="my-3">
                                <label class="form-label" for="MobileNo">MobileNo:</label>
                                <input type="number" name="phone" placeholder="25263XXXXXXX" id="MobileNo" class="form-control" required="required">
                            </div>
                        </div>
                                                   
                        <div class="form-group my-3">
                            <input type="submit" class="au-btn au-btn--block au-btn--green form-control rounded" value="submit" name="showChannel">
                        </div>
                 
            <?php echo form_close(); ?>


my controller code
    public function show(){
        if ($this->session->userdata('isUserLoggedIn')) {
            $this->load->view('incl/header');
            $this->load->view('incl/sidebar');
            $this->load->view('incl/navbar');
            $this->load->view('dash/access/view');
            $this->load->view('incl/datatable');
         
        } else {
            $this->load->view('incl/header');
            $this->load->view('login');
            $this->load->view('incl/script');
        }
    }


    public function getAccess(){


        $phone = $this->input->post('phone');
        $data = $this->AccessChannel->showAccess($phone);
        echo json_encode($data); 

    }

my model code

  public function showAccess($phone)
    {
        $this->db->select('createdat, SenderMobile,ReceiverMobile,transferid,Currency,ChannelName,shortCodeDailed');
        $this->db->from('loggingprofile2');


        $this->db->where('SenderMobile =',$phone);
        $query = $this->db->get();
        var_dump($this->db->last_query());
        // die();
        return $query->result();

I expect that where condition runs first as it in sql query but where condition returns NULL string(164) "SELECT createdat, SenderMobile, ReceiverMobile, transferid, Currency, ChannelName, shortCodeDailed FROM loggingprofile2 WHERE senderMobile IS NULL" Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 10489856 bytes)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB