Need help on serendipity SQL query..

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
andy0212
Posts: 2
Joined: Thu Oct 25, 2007 7:40 pm

Need help on serendipity SQL query..

Post by andy0212 »

Hello guys, I'm currently making a blog using Serendipity as the backend and Flash as the interface. But to get some info about my blog to appear at my Flash interface, such as yearly and monthly archives, it's quite complicated for me.

My problem is, in Wordpress, for example, the SQL query to count archives is

Code: Select all

SELECT DISTINCT YEAR( post_date ) AS `year` , MONTH( post_date ) AS `month` , count( ID ) AS posts
FROM andyWP_posts
WHERE post_type = 'post'
AND post_status = 'publish'
GROUP BY YEAR( post_date ) , MONTH( post_date )
ORDER BY post_date DESC
LIMIT 0 , 30
But because of Serendipity using timestamp and i'm not so familiar with timestamp, I have no clue what should I do. I'm sure that Serendipity already have their own SQL query for archives. But I can't trace how it works. I hope you guys can help me.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Need help on serendipity SQL query..

Post by garvinhicking »

Hi!

S9y uses PHP code to format the date/year. You can use the SQL functions "FROM_UNIXTIME" and "DATE_FORMAT" though to format a timestamp.Have a look at the MySQL documentation, then you can embed that in your SQL query.

If you don't succeed, tell me again in the middle of next week, then I can have a closer look if no one else can give you a full SQL query for it

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
andy0212
Posts: 2
Joined: Thu Oct 25, 2007 7:40 pm

Post by andy0212 »

Thank you for the tips! Before this I'm looking at the wrong SQL functions, now I know the answer. That's what I need for now. I will ask another question when I have one.

Thanks again. :D
Post Reply