如何从博客 table 中获取最近 3 post:magento

How to fetch recent 3 post from a blog table: magento

我在数据库中有一个 table 作为 "neotheme_blog_post" 并且那里有很多 post,现在我想从这个 [= 中获取最近的 3 post 17=] 并在主页上显示它们:我尝试按如下方式获取数据但没有任何效果:

    <?php $connection = 
      Mage::getSingleton('core/resource')->getConnection('core_read');
      $query      = "Select * FROM 'neotheme_blog_post'";
      $rows       = $connection->fetchAll($query);

      foreach ($rows as $values) {
      echo $name = $values['name'];

      }?>

你可以在这里使用LIMIT

$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$query      = "Select * FROM neotheme_blog_post LIMIT 3";
$rows       = $connection->fetchAll($query);
foreach ($rows as $values){
echo $name = $values['name'];
}

在我的例子中,我使用 neotheme 博客扩展获得了如下三个最近的帖子:

     $connection = 
     Mage::getSingleton('core/resource')->getConnection('core_read');
     $query = "Select * FROM neotheme_blog_post ORDER BY created_at DESC LIMIT 3 ";
     $rows = $connection->fetchAll($query);
     foreach ($rows as $values) {
     $post_titile = $values['cms_identifier'];
     echo '<div>';
     echo '<h1>' . $name = $values['title'] . '</h1>';
     echo $summery = $values['summary'];
     echo '<a href="' . $this->getUrl().'blog/'.  $post_titile . '">Read More</a>';
      echo '</div>';