On Jan 10, 2008 6:48 AM, maddiin <[EMAIL PROTECTED]> wrote:
>
> > entry:find({{date_part, year, created},'=',2008}).
> >
> > This would call "SELECT * FROM entry WHERE year(created) = 2008".
> >
> > Would that satisfy your requirements?
>
> Yes, for finding entries by a given date that would be good.
>
> How about finding dates where entries have been posted in?
>
> So I could display on my archive index the years (eg. 2008,2007,2006)
> if there are entries posted in this years. If I am on a year detail
> page, I want to show the month entries have been posted in.
>
> Instead of the star selector I want to query for "SELECT YEAR(created)
> FROM entry" and "SELECT MONTH(created) FROM entry WHERE YEAR(created)
> = 2008". I also need it for the sidebar and that would meet all the
> requirements then for making archive pages.
One option you have is to use the ErlyDB driver module directly, e.g.
erlydb_mysql:q({select, {date_field, year, created}}, from, entry}, Options),
but that's not a nice solution because of the dependency on the driver
and the need to write the full query and include the Options
parameter.
I think a better solution would be do add a function to erlydb_base
called "find_fields", which you could use to query for one or more
fields from a table mapped to a module, e.g.
entry:find_fields([id, {date_field, year, created}])
would return a list where each item is a tuple representing the row's
value, e.g. {1, 2007}.
You would also add a WHERE and LIMIT clauses as in other functions.
Would that be better?
Yariv
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"erlyweb" 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/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---