In the first example you could call $query->toArray() to get an array of article objects back.
The beauty is when you can start chaining stuff together, for instance custom find methods /thomas On 18 Aug 2014, at 16:59, Dave Edwards <[email protected]> wrote: > Hi, > > I'm having trouble getting my head around the new ways of working with the > new ORM in CakePHP 3. > > 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? > > 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? > > 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. > > 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? > > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/cake-php. > For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
