dongpan5289 2013-04-24 05:31
浏览 37
已采纳

从数据库问题中获取数据

i have one issue i make a component and i add data add component data table that i want to fetch that data in my site how to do and i have one other issue how to put query in view.html.php file in components i have code i add my code i have one error i add my error

500 - View class not found [class, file]: team_memberViewteam_member, C:\wamp\www\Joomla_2.5.8-Stable-Full_Package\components\com_team_member\views\team_member\view.html.php

this is my code please help me how to fetch data in database....

// import Joomla view library
jimport('joomla.application.component.view');

/**
 * HTML View class for the HelloWorld Component
 */
class HelloWorldViewHelloWorld extends JView
{
        // Overwriting JView display method
        function display($tpl = null) 
        {
                // Assign data to the view
                 $db = JFactory::getDbo();

// Create a new query object.
                $query = $db->getQuery(true);

// Select all records from the user profile table where key begins with "custom.".
// Order it by the ordering field.
            $query->select(array('id', 'member_name', 'member_pic', 'member_des','member_description'));
            $query->from('#__gztqw_team_member_datadetails');
            $query->where('profile_key LIKE \'custom.%\'');
            $query->order('ordering ASC');

// Reset the query using our newly populated query object.
            $db->setQuery($query);

// Load the results as a list of stdClass objects.
            $results = $db->loadObjectList();

                // Display the view
                parent::display($tpl);
        }
}
  • 写回答

2条回答 默认 最新

  • duanli9001 2013-04-24 05:36
    关注

    try simple way:-

    $db = JFactory::getDbo();
    $query = 'SELECT data FROM #__gztqw_team_member_datadetails WHERE profile_key LIKE "custom.%" order by ASC';
    $db->setQuery($query);
    $results = $db->loadObjectList();
    

    also you have not returened any value in function and where you have display it the best way to show data in view use controllers function and assign result value to display in view

    you need to read http://docs.joomla.org/Developing_a_Model-View-Controller_%28MVC%29_Component_for_Joomla!2.5

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大