dongyongju9560 2016-01-29 12:43
浏览 17
已采纳

如何从博客表中获取最近3篇帖子:magento

I have a table in database as "neotheme_blog_post" and there are many post in there, now i want to fetch recent 3 posts from this table and show them on home page: I have tried to fetch the data as follows but nothing worked:

    <?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'];

      }?>
  • 写回答

2条回答 默认 最新

  • dpbtbcz6650 2016-01-29 14:19
    关注

    In my case i get the three recent posts as like follows using neotheme blog extension:

         $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>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备