Jump to content


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

#CodeIgniter4

  • Please log in to reply
No replies to this topic

#1 pujaalifbudiman

pujaalifbudiman

    Newbie

  • Members
  • Pip
  • 2 posts
  • LocationPekanbaru, Indonesia

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.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users