我已经按照官方网页https://phpgrid.com/example/phpgrid-and-codeigniter-integration/的教程进行操作, 但是我的视图没有显示网格,我的数据库称为phpGrid并且有一个表producto,这个问题只发生在 CI 中,因为我已经在没有 CI 的情况下测试了 phpGrid_Lite并且可以正常显示网格。
(对不起,我的英语不好 :))
这是我的Welcome
控制器
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
//$this->load->view('welcome_message');
require_once(APPPATH. 'libraries/phpGrid_Lite/conf.php'); // APPPATH is path to application folder
$data['phpgrid'] = new C_DataGrid("SELECT * FROM producto", "id", "producto"); //$this->ci_phpgrid->example_method(3);
$this->load->view('show_grid',$data);
}
}
这是我的show_grid.php
文件
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Show Grid</title>
</head>
<body>
<div id="container">
<h1>Welcome to CodeIgniter! Show me the grid!</h1>
<div id="body">
<?php $phpgrid->display(); ?>
</div>
</div>
</body>
</html>
这conf.php
<?php
/**/
if (stripos($_SERVER['SCRIPT_NAME'], 'apps/phpgrid-custom-crm')) {
define('PHPGRID_DB_HOSTNAME', '127.0.0.1'); // database host name
define('PHPGRID_DB_USERNAME', 'root'); // database user name
define('PHPGRID_DB_PASSWORD', ''); // database password
define('PHPGRID_DB_NAME', 'phpGrid'); // database name
define('PHPGRID_DB_TYPE', 'mysql'); // database type
define('PHPGRID_DB_CHARSET','utf8'); // ex: utf8(for mysql),AL32UTF8 (for oracle), leave blank to use the default charset
} else {
//* mysql example
define('PHPGRID_DB_HOSTNAME','localhost'); // database host name
define('PHPGRID_DB_USERNAME', 'root'); // database user name
define('PHPGRID_DB_PASSWORD', ''); // database password
define('PHPGRID_DB_NAME', 'phpGrid'); // database name
define('PHPGRID_DB_TYPE', 'mysql'); // database type
define('PHPGRID_DB_CHARSET','utf8'); // ex: utf8(for mysql),AL32UTF8 (for oracle), leave blank to use the default charset
}
最后这是结果