I get the following error
CodeIgniter\Database\Exceptions\DatabaseException
You must set the database table to be used with your query
Using the code below ( it seems to me that tables name are set )
Any hint to fix the issue? Thanks a lot
In the Model is:
CodeIgniter\Database\Exceptions\DatabaseException
You must set the database table to be used with your query
Using the code below ( it seems to me that tables name are set )
Any hint to fix the issue? Thanks a lot
Code:
public function index(): string
{
$model = new RegisterModel();
$total->registrations = $model->countRegistrations();
$this->viewData['total'] = $total;
return view('pages/public/registers/civil/main', $this->viewData);
}Code:
namespace App\Models\Public\Registers\Civil;
use CodeIgniter\Model;
class RegisterModel extends Model
{
protected $DBGroup = 'registers';
protected $table_register = 'rci_combinations';
protected $table_registrations = 'rci_registrations';
protected $table_aircrafts = 'rci_aircrafts';
protected $table_models = 'aircraft_models';
protected $table_manufacturers = 'aircraft_manufacturers';
protected $table_pictures = 'rci_images';
...
...
public function countRegistrations($p = NULL, $id = NULL)
{
$builder = $this->db->table("$this->table_pictures");
$builder->select("
$this->table_register.id
");
$builder->from("$this->table_register");
$builder->join("$this->table_registrations", "$this->table_registrations.rid = $this->table_register.rid");
$builder->join("$this->table_pictures", "$this->table_register.id = $this->table_pictures.id");
$builder->join("$this->table_relations", "$this->table_relations.register_id = $this->table_register.id",'left');
$builder->where("$this->table_registrations.icao_id", '115');
if($p == 'operators')
{
$builder->groupBy("$this->table_register.rid");
$builder->where("$this->table_relations.operator_id", $id);
}
$query = $builder->countAllResults();
return $query;
}