⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Can I change the default CodeIgniter 4 database to apply to my GroceryCrud?



pujaalifbudiman

pujaalifbudiman
  • profile picture
  • Member

Posted 24 November 2020 - 03:14 AM

<?php

namespace App\Controllers;

use CodeIgniter\Controller;
use App\Libraries\GroceryCrud;
use App\Models\HalamanModel;
use App\Models\SubhalamanModel;
use App\Models\JurnalModel;

class Koleksi extends Controller
{
    public function __construct()
    {
        session();
        ini_set('memory_limit', '-1');
        ini_set('max_execution_time', '-1');

        $this->ModelHalaman     = new HalamanModel();
        $this->ModelSubhalaman  = new SubhalamanModel();
        $this->ModelJurnal      = new JurnalModel();
    }

    public function jurnal_umri()
    {
        $this->db = \Config\Database::connect('SmartSimpeg', true);

        $crud = new GroceryCrud();

        $crud->setTable('jurnal');

        $output = $crud->render();

        $output->title          = 'Daftar Jurnal &mdash; Pustaka UMRI';
        $output->halaman        = $this->ModelHalaman->getHalaman()->getResult();
        $output->subhalaman     = $this->ModelSubhalaman->getSubhalaman()->getResult();
        $output->jumlah_jurnal  = $this->ModelJurnal->getJumlahJurnal()->countAllResults();

        return view('koleksi/jurnal/v_jurnal', (array)$output);
    }
}

 

 

When I running that code, I receive error :

 

The table name does not exist. Please check you database and try again.