Dear,
I just used the previous community to enterprise, but the connection to the sql server did not work.
Configure my database.php:
[attachment=1281:database.php]
My Controller is :
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
// Add those two lines at the beginning of your controller
include(APPPATH . 'libraries/GroceryCrudEnterprise/autoload.php');
use GroceryCrud\Core\GroceryCrud;
class Mgi extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->database();
$this->load->helper(array('form', 'url','language'));
$this->load->library(array('ion_auth','Pagination','image_lib', 'session', 'form_validation','grocery_CRUD'));
$this->lang->load('auth','indonesian');
$this->load->helper("file");
}
private function _getDbData() {
$db = [];
include(APPPATH . 'config/database.php');
return [
'adapter' => [
'driver' => 'PDO_SQLSRV',
'host' => $db['default']['hostname'],
'database' => $db['default']['database'],
'username' => $db['default']['username'],
'password' => $db['default']['password'],
'charset' => 'utf8'
]
];
}
private function _getGroceryCrudEnterprise($bootstrap = true, $jquery = true) {
$db = $this->_getDbData();
$config = include(APPPATH . 'config/gcrud-enterprise.php');
$groceryCrud = new GroceryCrud($config, $db);
return $groceryCrud;
}
function _example_output($output = null) {
if (isset($output->isJSONResponse) && $output->isJSONResponse) {
header('Content-Type: application/json; charset=utf-8');
echo $output->output;
exit;
}
$this->load->view('mgi/t_header');
$this->load->view('mgi/v_content',(array)$output);
$this->load->view('mgi/t_footer');
}
public function index() {
if (!$this->ion_auth->logged_in())
{
redirect('login', 'refresh');
}
$this->_example_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
}
public function Customer() {
if (!$this->ion_auth->logged_in())
{
redirect('login', 'refresh');
}
try {
$crud = $this->_getGroceryCrudEnterprise();
$crud->setTable('Customers');
$crud->setSubject('Customer', 'Customers');
$crud->setRelation('KdSales','Salesman','NmSales');
$crud->columns(['NmLang','Alamat1','Kota1','Of_Phone1','Of_Email','KdSales']);
$crud->displayAs('NmLang','Customer Name.')
->displayAs('Alamat1','Address.')
->displayAs('Kota1','City.')
->displayAs('Of_Phone1','Phone.')
->displayAs('Of_Email','Email.')
->displayAs('KdSales','Account by.');
$crud->setPrimaryKey('KdLang','Customers');
$output = $crud->render();
$tampilan = (array)$output;
$tampilan['judul'] = "Tabel Customer";
$tampilan['link'] = '<li class="active">'.$tampilan['judul'].'</li>';
$tampilan['menu'] = "Menu Marketing";
$this->_example_output($tampilan);
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
when I call the subscriber then it does not display anything in v_content.
Please help me