[pLog-svn] r2091 - plog/branches/plog-1.1-ben/class/dao

Benjamin Krause ork at orkland.de
Tue May 31 14:19:49 GMT 2005


> Regarding this one huge method, I didn't see any other option because
> there are many different possible combinations of parameters. You
> created a getBlogArticlesByCategory, getBlogArticlesByDate,
> getBlogArticlesByDateAndCategory and so on, but how about a
> getBlogArticlesByDateAndCategoryAndStatusAndUser? Or a
> getBlogArticlesByDateAndUser? If you for example look at the
> administration page, under "edit posts", you will see that you've got
> plenty of filters... If we need a method for each one of those, we
> could go mental :)))

i've implemented another way, we should discuss this change, maybe on
MSN? might be easier ..

> This is where I get lost :( What would BlogArticles do? What is the
> advantage for us? Why don't we build the caching logic in Articles as
> you've done so far with all the other db-accessor classes?

okay i try to write down the way it is working now:

whenever you call getBlogArticles() this will not fetch exactly the
articles you had in mind but build an BlogArticles() Object.
The BlogArticles() object has all articles for a given blog, more
precisely a lot of array containing relations between search parameters
and article ids. BlogArticles() does not contain full articles, but only
ids.

e.g.:

  var $_articlesByCategory = array();
  var $_articlesByDate     = array();
  var $_articlesByStatus   = array();

we then fetch the articles you wanted to fetch calling
getBlogArticles(). this is done by asking BlogArticles() to filter all
articles by the filter we passed to getBlogArticles(), e.g.:

// get all released articles for the current blog
$requestedArticles = $blogArticles->getArticleIdsByStatus( $status );

// just get those articles that matches the given category
if( $categoryId > 0 ) {
  $requestedArticles =
    $blogArticles->getArticleIdsByCategory(

      $categoryId, $requestedArticles );
}

we do not need to issue any sql statement, every call to
getBlogArticles() will result in just a few array operations, filtering
the articleIds you really want to have.
this is faster then even calculating your complex select statements :)

then when getting the articleids, we call getArticle() with again has
all articles cached.

i would like to explain this in more detail when we both take a look at
the code :)

> 
> I have to admit that I haven't looked at BlogLinks yet, sorry, so I
> might be missing something obvious here...

yes, maybe :) its more or less a rebuild of the whole dao access layer :)

Ben



More information about the pLog-svn mailing list