DataMapper 1.6.0 |
[eluser]GregX999[/eluser]
Hey, I haven't been able to play with the new version very much yet - too much other work... But soon!! Also, I just wanted to say "Don't forget to update the docs." - if you haven't already updated them that is (these ones: http://stensi.com/datamapper/pages/toc.html). One reason I'm really liking both CI and DM is because of the excellent online docs with loads of examples. Be sure you keep those docs up to date for people just finding DM and wanting to see how it's used. I know it sucks writing docs when you could be improving the code, but without those docs, I wouldn't have even given DM much of a look at all. (Thanks for the mention in the credits... totally unnecessary, but thanks!) Greg
[eluser]hugslife[/eluser]
second that, your docs are very good, which is to say that they don't look like they were written by a coder :-) one thing i keep banging my head against, and it's probably that i'm just thick or doing things bass ackward, is iterating over an "open ended" list. Say I wanted a list of the books in my inventory, including JOIN'd authors names. given tables AUTHORS, BOOKS, and AUTHORS_BOOKS: Code: $b = new Book; The generated SQL: Code: SHOW COLUMNS FROM books Which is correct, exactly what I want, except that my foreach loop stops there after 1, not continuing down the list for each book in my inventory. any suggestions or advice is appreciated! and again, thanks for all your work with this library.
[eluser]stensi[/eluser]
Thanks guys :-) I know how important documentation is as well, so am making a point to update it along with each new version, to reflect the changes made. @Isuka: Thanks for letting me know. It looks like the same error will occur for strip_image_tags. @hugslife: The reason it's only doing the one book, is because you're only looping through the authors all list. You can't loop through both the books all list and the authors all list in one foreach loop. You'll need a foreach loop for each all list you want to loop through. So, here's how I'd loop through all your books, and then show all authors for each of those books: Code: // Get all books UPDATE Version 1.3.3 has been released! View the Change Log to see what's changed. In short, I fixed some validation rules (those that were overrides of incompatible CI Validation rules) and added in a couple of new validation rules (moved out of the Employee model example since I found them useful for many situations).
[eluser]Boyz26[/eluser]
Hi I am a little frustrated now so if anyone can help that would be great.. Whenever I do this, Code: function date2() It simply returns all entries from Book. I have not saved any relationships yet, so by right it should not display anything. Can someone tell me what I did wrong here? Thank you.
[eluser]stensi[/eluser]
@Boyz26: It's hard to know what's wrong without any real context to your issue. Could you show me how you've setup your Person and Book models? If you have no relationships saved then no relationships will be returned by DataMapper so you must have something setup wrong somewhere
[eluser]Isuka[/eluser]
I'm wondering how I can handle validation in the case I have a "has one" relation. I have something like this : Client model : Code: class Client extends DataMapper Category model : Code: class Category extends DataMapper In the case I want insert a new client, I need the name, eventually the website and the category the client belong to. The category is required. In my view form, I set up an input for the name and the website, and a dropdown menu for the category. How can I make the dropdrown menu required ? Is this handle by DataMapper ?
[eluser]stensi[/eluser]
Hmm, well since you're requiring the Category ID when saving a new Client, I'd put an extra validation rule in the Client model. In Client model Code: array( I'm assuming the drop-down list with your Categories has the Category ID's as the keys, and the Category Titles as the values. Also, that your form post sends the choice as "category_id". When you save the new Client, you'll need to save the relationship separately. Example: Code: // Create client object I'll be releasing a new version soon that handles the non-Database Table field validation rules a little differently, in that it will have a separate setting so the developer can specify whether the rules for those are run both when creating and updating a record, or just when creating.
[eluser]Isuka[/eluser]
Arf i didn't think about adding a fake rule to client model %-P My controller part is pretty like your exemple so it's work fine. Is it really not possible to save a relation on an non-existing object ? It would be really great if I can have a controller like that : Code: function edit ($id = '') Also a great feature would be to have the ability to delete a row without the need to make a get() before Code: // Exemple : delete a user by his ID (Sorry for my bad (very bad) english)
[eluser]Boyz26[/eluser]
[quote author="Boyz26" date="1223298057"]Hi I am a little frustrated now so if anyone can help that would be great.. Whenever I do this, Code: function date2() It simply returns all entries from Book. I have not saved any relationships yet, so by right it should not display anything. Can someone tell me what I did wrong here? Thank you.[/quote] My models are as below: Code: //models/person.php Code: //models/book.php Can you tell me what is wrong with it? Thanks again! |
Welcome Guest, Not a member yet? Register Sign In |