Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Help doing this in CakePHP
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Chad Casselman  
View profile  
 More options Nov 3, 10:29 am
From: Chad Casselman <ccassel...@gmail.com>
Date: Mon, 2 Nov 2009 18:29:25 -0500
Local: Tues, Nov 3 2009 10:29 am
Subject: Help doing this in CakePHP
I have a table that looks like:

id      created         modified        domain_id       pages   search_engine_id
92      2009-11-02 14:32:11     2009-11-02 14:32:11     2       19990   3
90      2009-11-02 14:32:11     2009-11-02 14:32:11     2       725     1
89      2009-11-02 14:32:10     2009-11-02 14:32:10     1       1250    1
88      2009-11-02 10:00:07     2009-11-02 10:00:07     2       19995   3
87      2009-11-02 10:00:07     2009-11-02 10:00:07     1       9612    3
86      2009-11-02 10:00:07     2009-11-02 10:00:07     2       725     1
85      2009-11-02 10:00:07     2009-11-02 10:00:07     1       1250    1
84      2009-11-02 09:59:47     2009-11-02 09:59:47     2       19995   3
83      2009-11-02 09:59:47     2009-11-02 09:59:47     1       9609    3
82      2009-11-02 09:59:47     2009-11-02 09:59:47     2       725     1
81      2009-11-02 09:59:47     2009-11-02 09:59:47     1       1250    1
80      2009-11-02 09:59:39     2009-11-02 09:59:39     2       19995   3
79      2009-11-02 09:59:39     2009-11-02 09:59:39     1       9609    3
78      2009-11-02 09:59:39     2009-11-02 09:59:39     2       725     1
77      2009-11-02 09:59:39     2009-11-02 09:59:39     1       1250    1

I have spent over half the day trying to figure out how to pull the
last inserted row for each domain_id, search_engine_id pair in
CakePHP.

Can anyone help me figure out how to do this within CakePHP?

I really appreciate your time.
Chad


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pablo Viojo  
View profile  
 More options Nov 3, 10:36 am
From: Pablo Viojo <pvi...@gmail.com>
Date: Mon, 2 Nov 2009 20:36:27 -0300
Local: Tues, Nov 3 2009 10:36 am
Subject: Re: Help doing this in CakePHP

Something like this may help:

SELECT domain_id, search_engine_id, MAX(id) FROM table GROUP BY domain_id,
search_engine_id

Regards,

Pablo Viojo
pvi...@gmail.com
http://pviojo.net

¿Que necesitas?
http://needish.com


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chad Casselman  
View profile  
 More options Nov 3, 10:49 am
From: Chad Casselman <ccassel...@gmail.com>
Date: Mon, 2 Nov 2009 18:49:35 -0500
Local: Tues, Nov 3 2009 10:49 am
Subject: Re: Help doing this in CakePHP
Is there anyway to get all the row information with all those ids or
does it require another query to get row details for returned ids?

Thanks,
Chad


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pablo Viojo  
View profile  
 More options Nov 3, 11:11 am
From: Pablo Viojo <pvi...@gmail.com>
Date: Mon, 2 Nov 2009 21:11:22 -0300
Local: Tues, Nov 3 2009 11:11 am
Subject: Re: Help doing this in CakePHP

You can do something using subqueries (but if you're quering the same table
on main and sub query, it will not perform well)

I recommend to do two queries instead.

Regards,

Pablo Viojo
pvi...@gmail.com
http://pviojo.net

¿Que necesitas?
http://needish.com


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chad Casselman  
View profile  
 More options Nov 3, 11:41 am
From: Chad Casselman <ccassel...@gmail.com>
Date: Mon, 2 Nov 2009 19:41:52 -0500
Local: Tues, Nov 3 2009 11:41 am
Subject: Re: Help doing this in CakePHP
Any idea how to use this approach with pagination?

Chad


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
schneimi  
View profile  
 More options Nov 3, 9:44 pm
From: schneimi <michael.schne...@arcor.de>
Date: Tue, 3 Nov 2009 02:44:50 -0800 (PST)
Local: Tues, Nov 3 2009 9:44 pm
Subject: Re: Help doing this in CakePHP
Hi,

if I understood you right, this could be what you need:

$result = $this->YourModel->find('all', array('group' => array
(domain_'id', 'search_engine_id'),
                                                               'order'
=> 'MAX(created)'));

With pagination it should look like this:

    $this->paginate['YourModel'] = array('group' => array(domain_'id',
'search_engine_id'),
                                                        'order' => 'MAX
(created)');
    $this->paginate('YourModel');

In both cases you can get related data with the 'contain' option in
the array.

Hope this helps,

Michael

On 3 Nov., 00:29, Chad Casselman <ccassel...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chad Casselman  
View profile  
 More options Nov 5, 6:00 am
From: Chad Casselman <ccassel...@gmail.com>
Date: Wed, 4 Nov 2009 14:00:28 -0500
Local: Thurs, Nov 5 2009 6:00 am
Subject: Re: Help doing this in CakePHP
Just to clarify, neither of the above works do to the fact the group
happens before the MAX, so MAX does not always return the max value,
normally the first.

Would still like to find a way to pull the latest row for set of data.

Chad


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
itc-media.com  
View profile  
 More options Nov 5, 7:23 pm
From: "itc-media.com" <xmlst...@gmail.com>
Date: Thu, 5 Nov 2009 00:23:03 -0800 (PST)
Local: Thurs, Nov 5 2009 7:23 pm
Subject: Re: Help doing this in CakePHP
how about using UNION ?

SELECT domain_id, search_engine_id, created, modified,  MAX(id) FROM
table GROUP BY domain_id
UNION
SELECT domain_id, search_engine_id, created, modified,  MAX(id) FROM
table GROUP BY search_engine_id

Regards,
Dragos

On Nov 4, 8:00 pm, Chad Casselman <ccassel...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google