I want to get data from database in admin section of my component. The strange thing is that the same code works on site part of my component but does not work on the admin part.
models/statistic_adm.php
<?php
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
jimport( 'joomla.database.database' );
jimport( 'joomla.database.table' );
class sblogModelstatistic_adm extends JModel
{
public function getCode(){
$db =& JFactory::getDBO();
$query = 'SELECT `code` FROM `#__sblog_ustawienia`';
$db->setQuery($query);
return $db->loadRowList();
}
}
views/statistic_adm/tmpl/default.php
<?php
// No direct access to this file
defined( '_JEXEC' ) or die('Restricted Access');
$document = JFactory::getDocument();
jimport( 'joomla.filter.output' );
$tabela = $this->get('getCode');
$code = $tabela[0][0];
?>
<form action="index.php?option=com_sblog&view=statistic_adm" method="post" name="adminForm">
<label>Kod bloga:</label> <input type='text' name='code' value="<?php echo $tabela[0][0]; ?>" />
<input type="hidden" name="task" value="" />
</form>
views/statistic_adm/tmpl/view.html.php
<?php
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.view');
class sblogViewStatistic_adm extends JView
{
function display($tpl = null)
{
JSubMenuHelper::addEntry(JText::_('Ustawienia'), 'index.php?option=com_sblog&view=statistic_adm', true);
JToolBarHelper::title( JText::_('System blogowy'), 'generic.png' );
$task = JRequest::getCmd('task');
$model = &$this->getModel('statistic_adm');
//$model=JFactory::getDBO();
$getCode = $model->getCode();
$this->assignRef('getCode', $getCode);
$this->addToolBar();
parent::display($tpl);
}
protected function addToolBar() {
if (JRequest::getVar('layout') != 'edit')
{
JToolBarHelper::save('save','Zapisz');
}
}
}
I appreciate any help.