$source = $this->load->database('source_db', TRUE);
$target = $this->load->database('target_db', TRUE);
$this->myforge = $this->load->dbforge($target, true);
$fields = $source->field_data($table);
$fields2 = array();
foreach ($fields as $fld)
{
$fields2[$fld->name] = (array) $fld;
$fields2[$fld->name]['null'] = true;
unset($fields2[$fld->name]['name']);
if ($fields2[$fld->name]['default'])
{
$fields2[$fld->name]['default'] = (string) $fields2[$fld->name]['default'];
} else
{
unset($fields2[$fld->name]['default']);
}
if ($fields2[$fld->name]['max_length'])
{
$fields2[$fld->name]['constraint'] = (int) $fields2[$fld->name]['max_length'];
unset($fields2[$fld->name]['max_length']);
}
unset($fields2[$fld->name]['primary_key']);
}
$this->myforge->add_field($fields2);
$this->myforge->create_table($table, TRUE);