Я хочу получить данные из базы данных в разделе администратора из одной таблицы моего компонента. Я пытался следовать [ Joomla 2.5 компоненту, получающему данные из базы данных по admin , но ничего не отображается.
- Имя моего компонента - com_payment_info
- Модель -> show_payments. php
models / show_payments. php
<?php
/**
* @version 1.0.0
* @package com_payment_info_1.0.0_j25x
* @copyright Copyright (C) 2019. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.application.component.modellist');
jimport('joomla.application.component.model');
jimport( 'joomla.database.database' );
jimport( 'joomla.database.table' );
class Payment_infoModelShow_payments extends JModelList
{
public function getCode(){
$db =& JFactory::getDBO();
$query = 'SELECT `user_name` FROM `#__new_payment`';
$db->setQuery($query);
return $db->loadRowList();
}
}
views/show_payments/view.html.php
enter code here
class Payment_infoViewShow_payments extends JViewLegacy
{
protected $items;
protected $pagination;
protected $state;
/**
* Display the view
*/
public function display($tpl = null)
{
$this->user = JFactory::getUser();
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$task = JRequest::getCmd('task');
$model = &$this->getModel('show_payments');
$getCode = $model->getCode();
$this->assignRef('getCode', $getCode);
// Check for errors
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors));
}
Payment_infoHelpersPayment_info::addSubmenu('show_payments');
$this->addToolbar();
$this->sortFields = $this->getSortFields();
// Load the template header here to simplify the template
$this->loadTemplateHeader();
parent::display($tpl);
}
?>
views/show_payments/tmpl/default.php
enter code here
<?php
// No direct access
defined('_JEXEC') or die;
$document = JFactory::getDocument();
jimport( 'joomla.filter.output' );
//get the value assigned in the view.html.php
$tabela = $this->getCode;
// print_r($tabela);
//$code = $tabela[0][0];
?>
<?php $listOrder = $this->listOrder; ?>
<?php $listDirn = $this->listDirn; ?>
<form action="index.php?option=com_payment_info&view=show_payments" method="post" name="adminForm">
<label>User Name:</label> <input type='text' name='code' value="<?php echo $code; ?>" />
<input type="hidden" name="task" value="" />
</form>
Я ценю любую помощь.