DMZ 1.7.1 (DataMapper OverZealous Edition) |
[eluser]OverZealous[/eluser]
One thing I didn't include: don't forget to escape your output (ie: the last bit should have been: Code: <input name="username" value="<?php echo htmlspecialchars($object->username) ?>" />
[eluser]YaZz[/eluser]
First off, just want to say, friggin' nice work! Now working with this concept, I feel that my head just can't get around some parts, or simply put, I'm just incredibly dumb at the moment. What I'm trying to achieve is grouping up tables nicely to make accessing easy. I have a table for categories, products and product_images. I've set up the models like this: Code: class categories extends DataMapper{ Code: class products extends DataMapper{ Code: class product_images extends DataMapper{ My problem here is... how do I actually access the product_images. I can get to the products... But that's it. Am I thinking this the wrong way or is there another way to actually achieve my goals?
[eluser]OverZealous[/eluser]
@YaZz First off, you've got some naming issues. Your classes need to be singular: category, product, and product_image. (The tables, however, need to be plural.) With the updated inflector helper, DMZ will handle the name conversions. You'll also need to update your $has_one and $has_many arrays in the same manner. Then, you access them like this: Code: $cat = new Category($cat_id); // or find it in a loop, etc. Of course, you can look up a product directly. Take a look at the example code included with the example application. It was in the full download. There are examples of all of this and more. ![]()
[eluser]zombaya[/eluser]
Hi, I'm experiencing something weird and I don't know how to solve it. I get an error-report when trying to update an object. The code I'm trying to run: Code: $v = new vak(); Code: keuzevak: objectgericht progr. // This is the correct result for $v->naam Code: class vak extends DataMapper{ Am I doing something wrong or is this a bug?
[eluser]OverZealous[/eluser]
@zombaya Please see the troubleshooting guide. This question is answered there.
[eluser]zombaya[/eluser]
That was indeed my problem, thank you very much. I'll look there first the next I encounter something like that.
[eluser]Skipper[/eluser]
I am using jQuery.tools for forms validation before handing the form over to DMZ for validation. Any DMZ validation erros go back to jQuery validation for showing the error messages. It would be good to have the field name plus the error message from $dmz->error->all, ie. I would prefer to access this like Code: foreach($si->error->all as $field => $error) { ... From what I see, slightly changing the DMZ function error_message($field, $error) (line 2599) to Code: $this->error->all[$field] = $this->error->{$field}; Thanks for DMZ, Phil! Great work!
[eluser]OverZealous[/eluser]
@Skipper That seems safe - I'll look into it when I get time to update DMZ next. You can also easily do this: Code: foreach($si->error as $name => $value) { It's not as clean, since you have to exclude the all and string fields. Also, your way is a lot easier if you are trying to export the error object as a JSON object. |
Welcome Guest, Not a member yet? Register Sign In |