[wp-hackers] $single
Hadley Wickham
h.wickham at auckland.ac.nz
Wed Jun 16 06:23:57 UTC 2004
> Query string syntax is a very convinent way to pass arguments to complex
> functions without having a thousand arguments. (See some of the link
> functions.) parse_str() makes this incredibly easy.
Yeah, but I was hoping for something a bit more like
$postsquery->setMonth(10)
$postsquery->setCategory("general", "exciting")
$posts = $postsquery->getMatching()
Why is this an advantage?
Well, I think it's a bit more obvious what's happening than $post =
get_posts("m=10&c[]=general&c[]=exciting") (or whatever the query string
would actually be).
It's easy to add new ways of filtering the data without thinking how
they would fit into the query string. eg.
$postquery->setStatus("drafts") (and thus you could reuse the code for
retrieving stuff for the admin interface)
Maintenance would be a bit easier because you'll have lots of small
methods instead of one huge one.
(Not that I'm complaining or anything :P )
Hadley
More information about the hackers
mailing list