In 1.2 : $this->Post->find('first', array('conditions' => array('post.category_id' => intval($catId)), 'order' => 'post.id DESC'));
On 10 mai, 13:39, "Olexandr Melnyk" <[EMAIL PROTECTED]> wrote: > If you're using CakePHP 1.1, something like this should do the job: > > $this->Post->findAll('catid = ' . $catid, array('field1'), 'id DESC', 1, 0); > > Don't forget to make sure that $catid is an integer. > > On 5/10/08, koko <[EMAIL PROTECTED]> wrote: > > > > > > > Hello, > > > I've searched this group and all other resources (bakery, manual, > > book, API), but I found no useful results ... > > > I have a table and that table contain some fields (it's only one table > > no HABTM here and no two tables relations): > > > id > > . > > . > > catid > > . > > . > > > I just mentioned the important fields ... > > > and I have a function that takes $catId as parameter > > > function getLastPost($catId) { > > $this->set('post', $this->Post->findByCatid($catId)); > > } > > > this function return an array of results where the table field 'catid' > > = $catId (the parameter) > > > what should i do to return only one result ordered by (table field) id > > desc, because I want only the one result with the last id (I want to > > use to show the last post from many categories) > > > I mean something like that: > > > SELECT * FROM posts WHERE catid = $catId ORDER BY id DESC; > > > if I stick with this solution (give cake a query) ... cake returned an > > array based on 0,1,2,... locations but the API methods (find, > > findBy..) returned different array, based on table name instead of > > numbers > > > I want a cakePHP function to do this query and return a will formated > > array: > > > was that clear enough or not :S ?? > > -- > Sincerely yours, > Olexandr Melnykhttp://omelnyk.net/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---