php - Codeigniter get all rows from db -


i'm working on task manager have 2 types of user: administrators(all privileges), , users(limited privileges).

here's task function in controller

function task($id) {     $data = array(         'query' => $this->main_model->get_task($id),         'task_id' => $id,         );     $data2['comments'] = $this->main_model->get_comments($id);      $this->load->library('form_validation');     $this->load->helper('security');      $this->form_validation->set_rules('comment_text', 'comment_text', 'trim|required|strip_tags|xss_clean');      if ($this->form_validation->run() === false)     {         if($this->main_model->get_task($id))         {             foreach ($this->main_model->get_task($id) $tas)             {                 $data = array(                     'title' => $tas->task_name,                     'desc' => $tas->task_description,                     'date_created' => $tas->date,                     'date_started' => $tas->task_start_date,                     'deadline' => $tas->task_deadline,                     'creator' => $tas->task_creator,                     'owner' => $tas->task_owner,                      'attach'=>$tas->attachment_name,                     'status'=>$tas->task_status,                     'priority'=>$tas->task_priority,                     'task_id'=>$tas->id_task,                     'base_url' => base_url()                     );             }             $data1 = array(                 'emps' => $this->main_model->get_employees(),                 'creator' => $this->main_model->get_details($id),                 'owner' => $this->main_model->get_owner($id)                 );              if ($this->session->userdata('employee_type') == 3) {               $qu = $this->main_model->permission();              $id = $this->session->userdata('id');              $id_emp = $this->uri->segment(3);              //foreach ($qu $q) {             if (in_array($id, $qu[0]) && in_array($id_emp, $qu[0])) {                  $this->load->view('task', array_merge($data, $data1, $data2));               }            else {                 echo "no permission access task";                 }             }         }     }     else     {         $config['upload_path'] = './uploads/';         $config['allowed_types'] = 'doc|docx|pdf|txt|text|rtf|jpg|gif|png';          $config['max_size'] = '1024';          $this->load->library('upload', $config);          if (!$this->upload->do_upload()) {                if ("you did not select file upload." != $this->upload->display_errors('','')) {                   $error = array('error' => $this->upload->display_errors());                 $this->load->view('task', $error);             }               else {                   $this->main_model->set_comments($id);                 redirect(current_url());             }           }           else {               $data = array('upload_data' => $this->upload->data());             $data1 = $this->upload->data();             $data2 = $data1['file_name'];             $this->main_model->set_comments($id);             $this->main_model->set_attachment($id, $data2);             redirect(current_url());         }       } 

}

and permission function in model:

function permission() {     $query = $this->db->get('employees_tasks');     $ret = $query->result_array();       return $ret; } 

what i'm trying is, data database employee_tasks check if id_task , id_employee in same row in database, can't working, getting first row of database, not others, , that's key problem, rows db. tried query database result, result_array, row, row_array, reason listing first row in db. appreciated.

to results separate table using codeigniter active record can this

function permission() {    $this->db->select("*");    $this->db->from("employees_tasks");    $this->db->where('id', 'your id');    $query = $this->db->get();            return $query->result();    // or    $query = $this->db->query("select * employees_tasks condition");    return $query->result(); } 

hope makes sense


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -