Welcome Guest, Not a member yet? Register   Sign In
Best practices using multiple object instances?
#8

[eluser]scherman[/eluser]
[quote author="WanWizard" date="1280349303"]The queries DMZ creates aren't that much different from what you normally would write.

And nobody's forcing you to use DMZ for ALL queries, I have DMZ models with custom methods that bypass DMZ entirely, and run their own $this->db queries, for exactly this reason. The beauty is that you can do both.

If the above code bothers you, create a MY_Loader extension:
Code:
class MY_Loader extends CI_Loader
{
    function MY_Loader()
    {
        parent::CI_Loader();
    }

    function object($class)
    {
        if ( file_exists(APPPATH.'classes/'.$class.EXT) )
        {
            require_once(APPPATH.'classes/'.$class.EXT);
        }
        else
        {
            return FALSE;
        }
        // you need to check if the file loaded ready defines the requested class...
        $class = new $class;
        return $class;
    }
}

and then use

Code:
$myclass = $this->load->object('myclass');
[/quote]

This is pretty cool. I have the same problem and i don't know how can i resolve it.
But i have a question about this: is there any way to work in my object class with the Active Records ($this->db....)? Because if i can do that, my problem will be resolved!


Messages In This Thread
Best practices using multiple object instances? - by El Forum - 07-28-2010, 08:49 AM
Best practices using multiple object instances? - by El Forum - 07-28-2010, 09:07 AM
Best practices using multiple object instances? - by El Forum - 07-28-2010, 09:26 AM
Best practices using multiple object instances? - by El Forum - 07-28-2010, 09:35 AM
Best practices using multiple object instances? - by El Forum - 07-28-2010, 12:04 PM
Best practices using multiple object instances? - by El Forum - 07-31-2011, 09:20 PM
Best practices using multiple object instances? - by El Forum - 08-01-2011, 01:34 AM
Best practices using multiple object instances? - by El Forum - 08-11-2011, 06:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB