DMZ 1.7.1 (DataMapper OverZealous Edition) |
[eluser]PoetaWD[/eluser]
Does it work for deep relationships ? Like this: Code: $obj->or_like_related('avaliator/company/manager', 'name', $this->input->post('sSearch')); Sorry for double posting... I just wanted to add some more information ....
[eluser]OverZealous[/eluser]
@Poetawd Yes. It's just part of Get Advanced. Most normal query clauses can have _related appended to them, and you get a related query, instead of a simple column query. Deep relationships are supported for most query clauses. The new job is going well. It's not exactly what I expected, but my coworkers are extremely nice.
[eluser]PoetaWD[/eluser]
Thanks Phil ! It works perfectly! DMZ impresses me more and more every day ! What is missing for it to be perfect ? (This is not a question... it is just a thought!) You dont sound very excited about your job.... but ... good to know that you like your new fellows...
[eluser]ianbborg[/eluser]
Hi there, I'm developing my first application with DMZ datamapper and it does save me alot of time so thanks for taking the time to develop it. I'm having a problem with relationships, are the models of a relationship auto-loaded? or do I need to load them in the constructor... Without loading the models I get this error message from php - Code: Fatal error: Class 'town' not found in C:\xampp\htdocs\NEWSDT\sdt\application\libraries\datamapper.php on line 4472 I have searched everywhere and found no solution but in the examples the models of a relationship arent loaded.
[eluser]ianbborg[/eluser]
Solved this problem. I was developing a module in the modules folder and the models where in the modules folder. So I setup a config var named $config['model_path']; which is then added to the path of the autoload function like this: Code: $file = $path . DataMapper::$config['models_path'] . 'models/' . $class . EXT; Now I have another problem with the relationships, table names seem to be duplicated in the query made by DMZ DM Why is this happening(maybe incorrect relationships) : Code: Table 'sdt.general_county_general_towns_country' doesn't exist Proper Table names are 1.general_towns_country 2.general_country 3.town 4.county 1.general_towns_country Model Code: class TownsCountry extends DataMapper 2.general_country Model Code: class Country extends DataMapper 3.town Model Code: class Town extends DataMapper 4.general_county Model Code: class County extends DataMapper
[eluser]OverZealous[/eluser]
@ianbborg The table name being generated is a join table. At least, I have to assume that, because you didn't include the code that generates this query. You probably are intending to use ITFKs, but you have them mis-named. If DMZ doesn't see the ITFK name on the table, it assumes there is a dedicated join table. The reason the table name appears twice is DMZ always adds an alias to the table name, to allow for advanced and deep queries. Your problems are most likely stemming from the fact that your model names and table names are very different. While it is possible to do this with DMZ, the ability to use a different $table name than the generated one is specifically for helping with unusual pluralizations, not for complete renames. The way you are using it is not supported, so I can't help you figure out your problem further. (Just like how "modules" aren't supported.)
[eluser]ianbborg[/eluser]
First of all thanks for your response, secondly I resolved the problem by doing advanced relationships using the "class" and "other field" fields. For the models that don't use the same name as in the db I named the key of the relationship as the database name: Code: class TownsCountry extends DataMapper The only problem remaining is when I try to save a TownsCountry object and I pass a Town & Country object as parameters, it doesn't seem to generate the SQL for the Country object so I save it by giving it the values instead.
[eluser]OverZealous[/eluser]
@ianbborg I'm glad you got it resolved, I just want to be clear that this is not how DMZ is designed. If you design your database and models according to the rules in the manual, just about everything you did is automatically handled. ![]()
[eluser]Mareshal[/eluser]
I want to change the default folder for loading models. Is there any setting for this? I modified the code: libraries/datamapper.php:811 $file = $path . "datamapper/" . $class . EXT;
[eluser]OverZealous[/eluser]
There is no setting. DMZ uses the standard CodeIgniter models directory. There was some code provided by Jack Scott that should help with CI 2.0 and EE, because those apparently allow for multiple model directories. However, all you have to do is register your own spl_autoload function. You don't need to modify DMZ at all. You can register this in a globally-loaded helper, library, or even a DMZ extension. |
Welcome Guest, Not a member yet? Register Sign In |