How can i specify which database to use using Ignited datatables library and codeigniter below is my code:
site.php - controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Site extends CI_Controller {
public function index()
{
$this->load->view('post');
}
public function getdatabyajax()
{
$this->load->library('Datatables');
$this->datatables
->select('username,email,salt')
->from('users');
echo $this->datatables->generate();
}
}
post.php - view
.....
.....
<script type="text/javascript" language="javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "<?php site_url(); ?>index.php/site/getdatabyajax",
"sServerMethod": "POST"
} );
} );
</script>
.....
.....
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<tr>
<th width="20%">Username</th>
<th width="25%">Email Address</th>
<th width="25%">Salt</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="5" class="dataTables_empty">Loading data from server</td>
</tr>
</tbody>
</table>
.......
......
any help is greatly appreciated!
site.php - controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Site extends CI_Controller {
public function index()
{
$this->load->view('post');
}
public function getdatabyajax()
{
$this->load->library('Datatables');
$this->datatables
->select('username,email,salt')
->from('users');
echo $this->datatables->generate();
}
}
post.php - view
.....
.....
<script type="text/javascript" language="javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "<?php site_url(); ?>index.php/site/getdatabyajax",
"sServerMethod": "POST"
} );
} );
</script>
.....
.....
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<tr>
<th width="20%">Username</th>
<th width="25%">Email Address</th>
<th width="25%">Salt</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="5" class="dataTables_empty">Loading data from server</td>
</tr>
</tbody>
</table>
.......
......
any help is greatly appreciated!