I can't get Table class to work in a controller. I try to get the data of a record in a table but I always get
0 Call to a member function load() on bool
Is it possible to use the Table class in a controller? What could be omitting?
administrator/components/com_aaprueba/src/Table/EspaciosTable.php
namespace Sfi\Component\Aaprueba\Administrator\Table;
defined('_JEXEC') or die;
use \Joomla\CMS\Table\Table;
use \Joomla\Database\DatabaseDriver;
class EspaciosTable extends Table
{
public function __construct(DatabaseDriver $db)
{
parent::__construct('#__sfi_es_espacios', 'id', $db);
}
}
components/com_aaprueba/src/Controller/EspaciosController.php
namespace Sfi\Component\Aaprueba\Site\Controller;
\defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Table\Table;
class EspaciosController extends FormController
{
public function getEspacio()
{
Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_aaprueba/src/Table');
$table = Table::getInstance('Espacios', 'Table', array());
$id = 2;
$table->load($id);
}
}