#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    33
    Rep Power
    2

    Codeigniter model!


    Hello can anyone help with this.
    I am trying to query single row in database in codeigniter model. Now I want to assign the queried data to a variable and insert the variable in another table. How can I do that

    This does not work. Thanks
    PHP Code:
    public function addSchedNRecordid(){
                
    $query $this->db->query('SELECT pcaseid FROM pcases order by 1 desc limit 1');
                
    $getLastRecorId $query->result_array();
                
    $insert = array('recordid' => $query->result_array());
                
    $this->db->insert('schedules'$insert);
            } 
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    you're calling $query->result_array() a second time instead of using $getLastRecorId. That should be the problem.

IMN logo majestic logo threadwatch logo seochat tools logo