Comments (4)
Can you show me a working example?
from datatables.
Bellow is my working code so far:
Codeigniter4Adapter.php
class Codeigniter4Adapter extends DBAdapter
{
protected $db;
protected array $config;
public function __construct($config = null)
{
if ($config != null) {
$this->config = $config;
}
if (!isset($this->config['DBGroup']))
{
$this->config['DBGroup'] = 'default';
}
}
public function connect()
{
$this->db = \Config\Database::connect($this->config['DBGroup']);
return $this;
}
PageModel.php
public function datatables()
{
$dt = new Datatables(new Codeigniter4Adapter(['DBGroup' => $this->DBGroup]));
$builder = $this->db->table($this->table . ' page');
$builder->select('page.id, page.title, template.name, page.status');
$builder->join('web_page_templates template', 'template.id=page.template_id','left');
$builder->orderBy('page.id DESC');
$dt->query($builder);
return $dt->generate()->toJson();
}
I add config array variable to Codeigniter4Adapter and pass DBGroup config via construct config parameter.
from datatables.
Thanks, I will update it tonight.
from datatables.
okay, thanks .
from datatables.
Related Issues (20)
- Which method adds optional parameters to the row? HOT 1
- Multiple value coloumn order HOT 2
- Add support for Embedded DataTable from Editor HOT 1
- Conditional where clauses for PhalconAdapter HOT 1
- MySQL error on special column names HOT 5
- addIndexColumn / DT_RowIndex
- Laravel adapter does not work with PostgreSQL
- PhalconAdapter not working
- Export to Excel feature HOT 1
- datatable: data with function, doesn't work sort HOT 1
- Problem when using sql server in codeigniter 4 adapter HOT 2
- data as array are forbidden
- Skip Total Records HOT 2
- edit all columns HOT 5
- weird error with the sorting of multiple columns HOT 1
- Mysql PDO HOT 2
- Large Table Count HOT 2
- Mysql table with dashes in name causes error HOT 15
- Filters HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datatables.