⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

get info from 2 relation table



DREON

DREON
  • profile picture
  • Member

Posted 03 June 2013 - 03:29 AM

hi to all masters,

 

i have 2 tables called

 

master_file

with columns:

 

               id  |  lname   | fname |      mi

ex.           2         cruz      robert      l

        

 

 

requirements

with columns:

 

              id |  master_file_id(relation to master_file id)  | submitted

ex.           1                      2                                                      yes

 

 

when i try this

 

    $crud->set_relation('id','requirements','{master_file_id}, {submitted}');

 

the relation on my requirements table not correct because they get id instead of master_file_id

 

 

 

now my question is: how can i get all the data from requirements table that are not yet submitted that show on my master_file table


davidoster

davidoster
  • profile picture
  • Member

Posted 03 June 2013 - 08:18 AM

This line,   $crud->set_relation('id','requirements','{master_file_id}, {submitted}');

is used in which table?

 

This question of yours: "how can i get all the data from requirements table that are not yet submitted that show on my master_file table" at least to me doesn't make sense!

What do you mean 'not yet submitted' ?

Please try to explain in details and post the existing code indicating where you have problems.


DREON

DREON
  • profile picture
  • Member

Posted 03 June 2013 - 22:21 PM

This line,   $crud->set_relation('id','requirements','{master_file_id}, {submitted}');

is used in which table?

 

That line use in masterfile table.. he crud relation get the id of my requirements table not master_file_id


davidoster

davidoster
  • profile picture
  • Member

Posted 04 June 2013 - 09:26 AM

I believe you can't do this. For several reasons.

1. this id is the primary_key of the table and it has a special function for Grocery CRUD.

2. how do you manage to display the id field? did you explicitly put it inside colums()?

 

I believe you need to change the way you work with this table.


DREON

DREON
  • profile picture
  • Member

Posted 04 June 2013 - 23:08 PM

using this add action button

 

$crud->add_action('Send', '', 'admin/main/sendrows', 'ui-icon-plus');

 

function sendrows($id) {
            $this->db->where('id',$id);
            $rs = $this->db->get('master_file')->row_array();
    
            $data['master_file_id'] = $rs['id'];
         
            $this->db->insert('requirements', $data);
   
        }

 

maybe i think using callback_column, but i dont know the code on how can i get the relation.


DREON

DREON
  • profile picture
  • Member

Posted 07 June 2013 - 10:00 AM

im now using callback_column to retrieve data from my requirements table to master_file table

 

but the result is error:

 

$crud->callback_column('requirements',array($this,'_callback'));

 

 

public function _callback()
    {
        $this->db->select();
        $this->db->from('master_file');
        $this->db->join('requirments','requirements.master_file_id = master_file.id');
        $query =  $this->db->get();
        return $query->result_array();
        
}

 

i want this result on my MASTER_FILE grid view

 

 

          requirements | id  |  lname   | fname |      m

                    yes         2         cruz      robert      l