Welcome Guest, Not a member yet? Register   Sign In
Using multiple databases with helper files
#8

[eluser]JoostV[/eluser]
Once again, it is very bad practise to put data handling in your helpers. Google why.

But, as a theoretical discussion, you simply pass the $db object as a parameter.
controller:
Code:
$db1 = $this->load->database('group_one', TRUE);
$result = some_function($db1);

helper:
Code:
function some_function($db){
    $query = $db->get('some_table');
    return $query->num_rows() > 0 ? $query->result_array() : array();
}


Messages In This Thread
Using multiple databases with helper files - by El Forum - 12-06-2009, 01:41 AM
Using multiple databases with helper files - by El Forum - 12-06-2009, 01:49 AM
Using multiple databases with helper files - by El Forum - 12-06-2009, 02:04 AM
Using multiple databases with helper files - by El Forum - 12-06-2009, 02:09 AM
Using multiple databases with helper files - by El Forum - 12-06-2009, 02:12 AM
Using multiple databases with helper files - by El Forum - 12-06-2009, 02:29 AM
Using multiple databases with helper files - by El Forum - 12-06-2009, 02:37 AM
Using multiple databases with helper files - by El Forum - 12-06-2009, 02:49 AM
Using multiple databases with helper files - by El Forum - 12-06-2009, 02:57 AM
Using multiple databases with helper files - by El Forum - 12-06-2009, 03:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB