Re: Recursion for my own custom query?

2007-06-19 Thread AD7six



On Jun 18, 3:03 pm, Joshua Benner <[EMAIL PROTECTED]> wrote:
> Looks good. I think I would use Cake's magic before writing my own function 
> like that,

Cake doesn't change the rules as far as DBs go.

If creating an extra table & model to avoid writing a GROUP BY
statement with some date functions is magic, then by all means.
However, considering doing that should make the hairs on the back of
your neck stand up - it would generate an instant WTF from   any DBA/
DB savy person upon sight ;).

Cheers,

AD


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Re: Recursion for my own custom query?

2007-06-18 Thread Joshua Benner





Looks good. I think I would use Cake's magic before writing my own
function like that, though. However, the function also accomplishes
more than the initial target functionality.

AD7six wrote:

  

On Jun 18, 1:55 pm, Joshua Benner <[EMAIL PROTECTED]> wrote:
  
  
Consider using a 'Months' table for which you define a 'Month' model which has associations defined between it and 'Entry'
Then:
$this->Month->findAll(array('monthName'=>'January'))

  
  
Or not :).

http://bin.cakephp.org/saved/20574

hth,

AD




  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake PHP" 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  -~--~~~~--~~--~--~---





Re: Recursion for my own custom query?

2007-06-18 Thread AD7six



On Jun 18, 1:55 pm, Joshua Benner <[EMAIL PROTECTED]> wrote:
> Consider using a 'Months' table for which you define a 'Month' model which 
> has associations defined between it and 'Entry'
> Then:
> $this->Month->findAll(array('monthName'=>'January'))

Or not :).

http://bin.cakephp.org/saved/20574

hth,

AD



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Re: Recursion for my own custom query?

2007-06-18 Thread Joshua Benner





Consider using a 'Months' table for which you define a 'Month' model
which has associations defined between it and 'Entry'

Then:
$this->Month->findAll(array('monthName'=>'January'))

Pete wrote:

  I have a function in my model, to get a list of the months that I have
blog entries in:

function getMonths($limit = null)
{

$sql = "SELECT DISTINCT month(Entry.date) number,
monthname(Entry.date) title, year(Entry.date) year FROM entries as
Entry ORDER BY date DESC";
if ($limit): $sql .= " LIMIT " . $limit; endif;

$result = $this->query($sql);
return $result;

}

What would be the best way to then get the Entries that are in those
months. Could I attach the Entries to those month results?

Basically, I'm trying a pretty typical "archive by month", and I'm
trying to get an array like:

[0] => Array
(
[Month] => Array
(
[number] => 5
[title] => May
[year] => 2007
)
[Entry] => Array
(
[0] => Array
(
[title] => Blog Post
[date] => May 06, 2007
)
[1] => Array
(
[title] => Blog Post
[date] => May 06, 2007
)
)
)

Any ideas?



  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake PHP" 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  -~--~~~~--~~--~--~---