On Dec 20, 12:03 pm, Tijs Teulings <[EMAIL PROTECTED]> wrote:
I might be daft but in these cases plain old SQL isn't all that bad is it...
$posts = $this->Post->query("SELECT DISTINCT Post.title, Post.body FROM
posts as Post
LEFT JOIN posts_tags as pt ON Post.id = pt.post_id
LEFT JOIN tags as Tag ON Tag.id = pt.tag_id
WHERE Tag.id = '$id' AND Post.published < NOW()");
I haven't tested the actual SQL but something like that should work like a
charm and the result would be a Cake compatible array.
SQL != evil :)
Tijs
SQL certainly isn't evil :)
However if you use query you lose any afterFind, beforeFind stuff plus
no ability to modify the recursiveness of the results (because there
can be no recursive model fetching behavior if you use query).
That's leaving aside that insecure sql is easy to write with query,
whereas with cake calls it's very much more difficult to do so and if
it's not just a select you'ld lose the validation, afterSave,
beforeSave, afterDelete, beforeDelete stuff too.
HTH,
AD7six
Please note:
The manual/bakery is a good place to start any quest for info.
The cake search (at the time of writing) erroneously reports less/no
results for the google group.
The wiki may contain incorrect info - read at your own risk (it's
mainly user submitted) :) You may get your answer quicker by asking on
the IRC Channel (you can access it with just a browser
here:http://irc.cakephp.org).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---