Thanks for the replies, Having thought about it, I think that main thing that currently confuses me is not the construction of the queries, but the process of getting to the data once the object has been returned. Previously I could just drop a pr($result) into the Controller or view and immediately see what data I had. If I try that now it comes up a structure where the data is buried in things like [_properties:protected] ?
Also the new ORM involves looping through the object (on some occasions, but not others) to get the data out using something like foreach ($query->all() as $person) ?? There's also the issue of getting at the data in the view (or templates as they are now called). If for example I had a one to many from Person to PersonSets and I used the following $persons = $this->Persons->find('all')->contain('Personsets') How do I get at both the person data and the associated sets. In CakePHP 2 I could loop through the associated data using something like foreach($persons['PersonSets'] as $set) How would this be done? I'm sorry if there are basic questions, but there is lot of example in your documentation on the new ORM, a lot on Controllers etc etc, but not many end to end examples (apart from the blog). Dave On Tuesday, 19 August 2014 10:16:42 UTC+1, José Lorenzo wrote: > > My answers are inline: > > On Monday, August 18, 2014 4:59:42 PM UTC+2, Dave Edwards wrote: >> >> Hi, >> >> I'm having trouble getting my head around the new ways of working with >> the new ORM in CakePHP 3. >> > > That's normal, given that you are a longtime CakePHP user, hopefully it > will make sense to you very fast :) > >> >> I understand that an object is now returned instead of an array, but I >> find the amount of new Documentation to explain the new methods of working >> with Models almost overwhelming. Whilst it is certainly well written, it >> seems to be pitched at a different (higher level) of user to previous >> versions. To give an example of this, the first paragraph explaining what >> Models are, it says 'interactions and evolution of the information >> workflow in your domain of work.' Sorry, but what does this really mean, >> in plain English? >> > > If you have been using CakePHP for some time, then I guess you don;t need > models to be explained to you. But in plain english, it is where the core > of your application exists, when any user interaction is taken away. That > is, all data processing, updating and the rules to follow to keep your data > sane. > > >> The documents also seem to switch backwards and forwards between >> different methods, such as the section called 'Find returns a query object' >> where it shows this method to return articles >> >> $articles = TableRegistry::get('Articles');$query = >> $articles->find();$query->where(['author_id' => 1])->order(['title' => >> 'DESC']); >> >> then it shows you this a few lines later >> >> $article = $this->Articles->find('all', [ >> 'conditions' => ['author_id' => 1]])->first(); >> >> which is much more like CakePHP 2. What's the difference, which should I >> be using and which is better. Do they give the same results? How do I get >> my data out of the objects? >> > > Both ways are exactly the same, we offered the 2 alternatives to make > users coming form 2.x feel more at home. I would say the first form is > preferred as it is more flexible. > > >> >> As a user of CakePHP 1.xx and 2.xx for the past 6 years, I am obviously >> comfortable using those versions of the framework, and the appeal of >> CakePHP to me has always been that it could be easily used by novices and >> professionals alike. I know that part of the complaint regarding previous >> versions of CakePHP was that queries returned data arrays, and not objects, >> and I'm sure that the changes to the Model layer will attract more >> professional users, but I hope that this isn't at the expense of those >> choosing a framework for the first time, or cutting their teeth on PHP. >> > > I don't think it is, on the contrary, I feel that the ORM is much more > approachable and understandable that its previous incarnations. > > >> >> Now before Mark, Mark and Jose etc. jump on me, I am not being critical >> of their fantastic efforts to modernise the framework, or the reasons for >> doing so. I am also not adverse to change, especially if it is for the >> better, which is why I am attempting to get to know this new version, even >> though it is still in Alpha, and yes I have read the documentation, but the >> more I read the more confused I get. >> >> I know that people at this stage will say, that if I could do better, >> then I should contribute to the documents myself. But in order to do so, I >> would need to understand them first! :) They do say that programmers >> shouldn't write manuals, and perhaps this is a case in point? >> > > I would like to know what is exactly confusing you, so we can help you > understand how things work. Let me also suggest buying tickets for > cakefest, much of the ORM internals, tips and tricks will be explained in > detail there :) > >> >> Dave >> >> >> -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.