⚠ 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 forum is read-only and soon will be archived. ⚠


glopezr

Member Since 12 Jun 2015
Offline Last Active Jun 15 2015 04:14 PM
-----

Posts I've Made

In Topic: dropdown without set_relation, but from different table

12 June 2015 - 09:39 AM

Thanks to all, as set_relation don't work when you use a table from other DB, I used this code to make the dropdown.
 
$crud = new grocery_CRUD();
$crud->set_table('testtable');
$crud->set_subject('TEST');

$crud->columns('id_sup',...............................................);

$DB1 = $this->load->database('otherdb', TRUE);

$query=$DB1->query("SELECT id, CONCAT (id,' - ',name) as fullname FROM supertabla WHERE activo=1 ORDER BY name ASC;");

$arr_ids = array();

foreach ($query->result() as $row)
{
    $arr_ids[$row->id]=$row->fullname;
}

$crud->field_type('id_sup','dropdown', $arr_ids);