Welcome Guest, Not a member yet? Register   Sign In
DMZ 1.7.1 (DataMapper OverZealous Edition)
#31

[eluser]OverZealous[/eluser]
@Jack Scott
Regarding the autoload method: it's going to be called anytime a class is requested that hasn't already been loaded, no matter where that class is called. (It's related to the way PHP loads classes.) Due to the required naming scheme (ie: that every model has to have a unique class name across the entire app, and the file name is the same as the class), it shouldn't ever cause an issue. (You cannot have any other classes with the same name as your DMZ models, just like you can't have any two classes with the same name, anywhere.)

I'm not ready to start worrying about CI 2.0 yet, and I don't have access to EE. Feel free to post it, but I'm probably not going to be worrying about it too soon.

I don't think there is an issue with letting CI load the models, other than if CI loads a model, that model gets instantiated whether or not it is used. If you let DMZ lazily load the models, then only the models needed for that request get loaded. I wasn't going to allow models to be loaded via CodeIgniter, even with the name change, just provide a better error, but I'll think about it. (It's important to realize that DMZ models aren't truly CodeIgniter models - they don't share any code with CI's models, and they work very differently.)
#32

[eluser]OverZealous[/eluser]
@Mareshal
I think you need to spend some time reading through the General Topics section of the manual.

The manual is fairly complete, if not perfect, and really discusses how DMZ works.
#33

[eluser]Spir[/eluser]
Edit: I was wrong. My bad. Deleted my post
#34

[eluser]rideearthtom[/eluser]
Thanks for the above comments. I'll continue using my workaround.

I have another situation that I'm unsure how to handle. Basically I want to create a relationship where the PK of the relationship is defined by the ids of three other models. A bit like a join table but with 3 FKs.

To put it into its real world example, I have two models, Project and Location, which have a M*M relationship, using a join table. I have another model, Document, and I want to relate this to the relationship between the Project and the Location. I can't use a field in the join table as that would only allow for one Document to be related. I'm not sure that it's a good idea to create another join table that relates Documents to the Project/Location join table. Maybe this is something else that I'll have to do outside of the DMZ framework?
#35

[eluser]Jack Scott[/eluser]
Hello Phil,

The updated autoload() method is included below. It uses the loader's _ci_model_paths property to locate models. I suspect this is intended to be a private property, and may not work in future versions, but we'll cross that bridge when we get to it.

Code:
public static function autoload($class)
    {
        // Don't attempt to autoload CI_ or MY_ prefixed classes
        if (in_array(substr($class, 0, 3), array('CI_', 'EE_', 'MY_')))
        {
            return;
        }

        // Prepare class
        $class = strtolower($class);

        // Prepare path
        $CI =& get_instance();
        if (isset($CI->load->_ci_model_paths) && is_array($CI->load->_ci_model_paths))
        {
            // use CI loader's model path
            $paths = $CI->load->_ci_model_paths;
        }
        else
        {
            $paths = array(APPPATH);
        }
        
        foreach ($paths as $path)
        {
            // Prepare file
            $file = $path . 'models/' . $class . EXT;
            
            // Check if file exists, require_once if it does
            if (file_exists($file))
            {
                require_once($file);
                break;
            }
        }
        
        // if class not loaded, do a recursive search of APPPATH for the class
        if (! class_exists($class))
        {
            DataMapper::recursive_require_once($class, APPPATH . 'models');
        }
    }
#36

[eluser]Buso[/eluser]
thanks for the great datamapper =)
#37

[eluser]OverZealous[/eluser]
@Buso
Err, Thanks! Guess I'm too fast. ;-)

I guess you found this page: http://ellislab.com/codeigniter/user-gui...cting.html
#38

[eluser]Buso[/eluser]
[quote author="OverZealous" date="1269000958"]@Buso
Err, Thanks! Guess I'm too fast. ;-)

I guess you found this page: http://ellislab.com/codeigniter/user-gui...cting.html[/quote]
ahahah

nah, its just that i never used it that way (or i lost my memory), AND i was loading it as a model or something, not a library (lol)

thanks again, ill never write a JOIN query again
#39

[eluser]OverZealous[/eluser]
@Jack Scott
I'll look into including that with DMZ 1.7.1, since it seems harmless.

@Everyone
Also, I'll fix the _assign_libraries problem, in some manner. I think I'm going to have DMZ log a warning, but not print any errors. You really shouldn't use CodeIgniter to load your DMZ models, but some might still want to use it that way.

Hope everyone has a great weekend. I'll look at rolling up these few bugfixes / changes and getting them out by Monday. 1.7.1 already has a new function (is_related_to), fixes to the examples and extensions that allow them to work with get_iterated, and some minor bugfixes.

If you have any other wishes for 1.7.1, now is the time to let me know! ;-)
#40

[eluser]rideearthtom[/eluser]
Other wishes: somehow include selected join fields with the json extension.

Any ideas on the above situation (#33)?

Keep up the good work!




Theme © iAndrew 2016 - Forum software by © MyBB