DataMapper ORM v1.8.2 |
[eluser]AAtticus[/eluser]
Thanks WanWizard, normally I scout the manual to find this information but I must have missed it. Sorry to ask for support for something trivial and well documented!
[eluser]smi23[/eluser]
[quote author="WanWizard" date="1348953432"] I find it difficult to believe that some PHP code in a model class can crash your webserver. And I don't understand what you want added to the reserved names. "organisation" isn't a reserved name.[/quote] Well, local server called 'Denwer' can. I mean, if the table in self-relationship model, like in http://ellislab.com/forums/viewthread/196220/#923408 will have the column named exactly like model name, then some error will happen while you trying to get some results (maybe memory exceeding or something). I've spent a lot of time trying to figure this out, so I'd like to help others to avoid that.
[eluser]WanWizard[/eluser]
There is no restriction for column names with relation to the current model. As both columns and relationships are accessed through model object properties, it's obvious that you can't give a relationship the same name as a column. It will cause your relationship not to work, as column data has preference. The first echo of the value will show you what's wrong, so I don't think it's much of an issue.
[eluser]AAtticus[/eluser]
WanWizard, How would you use datamapper to build a search query with optional search fields. in plain PHP/SQL I would check all the fields for empty, and build the query incrementally with only non empty search fields. Is something like this possible in datamapper?
[eluser]WanWizard[/eluser]
You can do the same: Code: // some example code, do not do it like this!
[eluser]AAtticus[/eluser]
I'm getting a really strange error. I've consultants and companies in a database. Companies can be clients or companies that external consultants work for. so Company has many Consultants. so Consultant has one Company. Now, I'm trying to create a Booking class where a Consultant is placed withing a Company for a specific period. So Booking has one Consultant and one Company And now Company has many Consultants and many Bookings And now Consultant has one Company and many Bookings in my database I have Code: consultant (id, name, company_id) If I try Code: $cu = new Consultant(); I get this warning: Code: A PHP Error was encountered And this Error: Code: Error Number: 1054 * If I remove the direct link between Consultants and Companies it works but then I don't know which consultants work for which companies. * why is it looking for a consultant_id in bookings_companies ? The link between consultants and bookings is in bookings_consultants.
[eluser]rick20[/eluser]
@AAtticus, does the $cu and $co already saved to database after building them from POST data? AFAIK when saving the relationship, datamapper need to know the relation's IDs. As for the error, what if you use the following as alternative: Code: $b->save_consultant($cu); hope that helps
[eluser]ninjayan[/eluser]
I am new to CodeIgniter and don't know what is datamapper orm. Anyone has a tutorial or any link for beginner to understand this? thanks!
[eluser]rick20[/eluser]
@ninjayan maybe you can start from the documentation http://datamapper.wanwizard.eu/ The documentation is clear enough to start writing codes with datamapper. There's also some examples here http://datamapper.wanwizard.eu/pages/examples.html
|
Welcome Guest, Not a member yet? Register Sign In |