Upgrading drupal 5 or 6 snippets to drupal 7

After I upgraded from drupal 5 to drupal 6 and then to drupal 7, I realized that some of my php snippets stopped working. So, I looked around and found a few links discussing it. As an example of a modification I had to do, here is snippet that prints out a list of nodes by content type (in this case 'blog') and by taxonomy id (in this case 12). It provides a list like this one:
  1. (2011 09 28)  Why don't I believe the that neutrinos travel faster than the speed of light?
  2. (2010 12 31)  From Masada to the Messinian Salinity Crisis
  3. (2010 02 03)  A visit to Stromboli
  4. (2008 01 11)  Bush in a quantum entangled state
  5. (2007 12 29)  Corpuscular Rays in St. Peter's Basilica (the Vatican)
  6. (2007 12 13)  A Nice Black Hole Merger Simulation
  7. (2007 04 22)  Parhelic Circles, Ice Haloes and Sun dogs over Jerusalem
  8. (2006 05 26)  Have you heard of the silent Earthquake?
The a drupal 5 (or drupal 6) version of the code looks like this:
1
2
3
4
56
7
8
9
1011
12
13
14
15
   $listlength="300";
   $taxo_id = "12";
   $content_type = 'blog';
   $result = pager_query("SELECT n.title, n.nid, n.uid, n.created, u.name FROM {node} n 
INNER JOIN {users} u ON n.uid = u.uid INNER JOIN term_node ON n.nid = term_node.nid WHERE n.type = '$content_type' AND term_node.tid in ($taxo_id) AND n.status = 1 
ORDER BY n.created DESC", $listlength); 
   unset ($output);
   $output = "<ol>";
   while ($node = db_fetch_object($result)) {        $output .= "<li><small>" .format_date($node->created,'custom','(Y m d)',
$timezone = NULL)."&nbsp;</small> ".l($node->title, "node/$node->nid") ."</li>";
   }
   $output .= "</ol >";
   print $output;


In drupal 7, this snippet should be modified since there is no pager_query anymore. The modified version I now have is
1
2
3
4
56
7
8
9
1011
12
13
14
1516
17
18
    $taxo_id = 12;
    $content_type = 'blog';
    $status = 1;  /* 1=published */
    $result = db_query("SELECT n.title, n.nid, n.uid, n.created  FROM {node} n INNER JOIN
{taxonomy_index} tn ON n.nid = tn.nid WHERE n.type = :type AND tn.tid in ( :term ) AND n.status= :status ORDER BY n.created DESC", array(
    ':type' => 'blog',
    ':status' => $status,
    ':term' => $taxo_id,
    ));    unset ($output);
    $output = "<ol>";
    foreach ($result as $node) {
        $output .= "<li><small>" .format_date($node->created,'custom','(Y m d)',
$timezone = NULL)."&nbsp;</small> ".l($node->title, "node/$node->nid") ."</li>";    }
    $output .= "</ol >";
    print $output; 

ContentType:

blog topic: