A quick lesson to me please, not capable of having my own sql query nor to use API yet I'm.
I wrote a little theme function to display posts either 1, 2 or 3 years ago (with parameters such as a time window, e.g. display posts between 1 year less 2 weeks to 1 year ...etc). How do I use the lastest API to do the same thing? On Thu, Sep 18, 2008 at 2:14 AM, Blake Johnson <[EMAIL PROTECTED]>wrote: > > > > This snippet from the wonderful (and now broken) monthly archives > > plugin illustrates the point beautifully > > > > $q= 'SELECT YEAR( p.pubdate ) AS year, MONTH( p.pubdate ) AS month, > > COUNT( p.id ) AS cnt > > FROM ' . DB::table( 'posts' ) . ' p > > WHERE p.content_type = ? AND p.status = ? > > GROUP BY year, month > > ORDER BY p.pubdate DESC ' . $limit > > > > Self-documenting, captures all the semantics in five lines, portable > > to all database platforms. > > > > I'd just like to point out that YEAR() and MONTH() are MySQL specific > funcitons. So, this query is not portable to all platforms. It > happened to work, previously, because we provided translations for > SQLite and PostgreSQL. > > I will also mention that you don't have to write your own query to do > this. It is provided by the API with: > $counts = Posts::get( array( 'month_cts' => 1, 'status' => > Post::status( 'published' ) ) ); > > If plugins use our API which abstracts DB details, upgrades will be > much less painful. > > --Blake > > > -- See me at http://am.notsowise.net --~--~---------~--~----~------------~-------~--~----~ 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/habari-dev -~----------~----~----~----~------~----~------~--~---
