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

[eluser]JoostV[/eluser]
Helpers are not classes, but merely functions containers. They do not have native access to the CI superobject.

You should do you data handling in the model. In models, you can reference the CI superobject as $this. Therefore, this should work:
Code:
$db1 = $this->load->database('group_one', TRUE);
$query = $db1->get();
if ($query->num_rows() > 0) {
   // Strut your stuff
}

If you need to use the CI superobject in a helper sometime anyway you have to pass it as a parameter.
Code:
echo some_helper_function($this);


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