irsyadulibad / ci4-datatables Goto Github PK
View Code? Open in Web Editor NEWServer Side Datatables Library for CodeIgniter 4 Framework
Home Page: https://ci4-datatables.netlify.app
License: MIT License
Server Side Datatables Library for CodeIgniter 4 Framework
Home Page: https://ci4-datatables.netlify.app
License: MIT License
I am getting this Class not found exception on a machine running Ubuntu 20.04
The possible workaround to this could be fixing captilization to the "utilities" directory to match with the correct namespace used.
saya coba get tabel dengan undescore selalu gagal
misal nama table : user_students
mohon pencerahannya
PHP Version: 8.1.2 (x64)
SQL Server Version: Microsoft SQL Server 2022 (RTM) - 16.0.1000.6 (X64)
Framework: Codeigniter 4.3.1
Hello,
I have a problem when using this library with this error message
[Microsoft][ODBC Driver 17 for SQL Server][SQL Server] Incorrect syntax near ')'.
here is my error debug:
{
"title": "CodeIgniter\\Database\\Exceptions\\DatabaseException",
"type": "CodeIgniter\\Database\\Exceptions\\DatabaseException",
"code": 500,
"message": "[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near ')'.",
"file": "D:\\Server\\ci-attend\\vendor\\codeigniter4\\framework\\system\\Database\\BaseConnection.php",
"line": 645,
"trace": [
{
"file": "D:\\Server\\ci-attend\\vendor\\codeigniter4\\framework\\system\\Database\\BaseBuilder.php",
"line": 1686,
"function": "query",
"class": "CodeIgniter\\Database\\BaseConnection",
"type": "->",
"args": [
"SELECT COUNT(*) AS \"numrows\"\nFROM \"ci-attend\".\"dbo\".\"employees\"\nWHERE (\n )",
[],
false
]
},
{
"file": "D:\\Server\\ci-attend\\vendor\\irsyadulibad\\codeigniter4-datatables\\src\\DataTableAbstract.php",
"line": 137,
"function": "countAllResults",
"class": "CodeIgniter\\Database\\BaseBuilder",
"type": "->",
"args": [
false
]
},
{
"file": "D:\\Server\\ci-attend\\vendor\\irsyadulibad\\codeigniter4-datatables\\src\\DataTableAbstract.php",
"line": 146,
"function": "countTotal",
"class": "Irsyadulibad\\DataTables\\DataTableAbstract",
"type": "->",
"args": []
},
{
"file": "D:\\Server\\ci-attend\\vendor\\irsyadulibad\\codeigniter4-datatables\\src\\QueryDataTable.php",
"line": 37,
"function": "countFiltered",
"class": "Irsyadulibad\\DataTables\\DataTableAbstract",
"type": "->",
"args": []
},
{
"file": "D:\\Server\\ci-attend\\vendor\\irsyadulibad\\codeigniter4-datatables\\src\\QueryDataTable.php",
"line": 27,
"function": "execQueries",
"class": "Irsyadulibad\\DataTables\\QueryDataTable",
"type": "->",
"args": []
},
{
"file": "D:\\Server\\ci-attend\\app\\Controllers\\Admin\\EmployeeManageController.php",
"line": 35,
"function": "make",
"class": "Irsyadulibad\\DataTables\\QueryDataTable",
"type": "->",
"args": [
true
]
},
{
"file": "D:\\Server\\ci-attend\\vendor\\codeigniter4\\framework\\system\\CodeIgniter.php",
"line": 934,
"function": "get_employees",
"class": "App\\Controllers\\Admin\\EmployeeManageController",
"type": "->",
"args": []
},
{
"file": "D:\\Server\\ci-attend\\vendor\\codeigniter4\\framework\\system\\CodeIgniter.php",
"line": 499,
"function": "runController",
"class": "CodeIgniter\\CodeIgniter",
"type": "->",
"args": [
{}
]
},
{
"file": "D:\\Server\\ci-attend\\vendor\\codeigniter4\\framework\\system\\CodeIgniter.php",
"line": 368,
"function": "handleRequest",
"class": "CodeIgniter\\CodeIgniter",
"type": "->",
"args": [
null,
{
"handler": "file",
"backupHandler": "dummy",
"storePath": "D:\\Server\\ci-attend\\writable\\cache/",
"cacheQueryString": false,
"prefix": "",
"ttl": 60,
"reservedCharacters": "{}()/\\@:",
"file": {
"storePath": "D:\\Server\\ci-attend\\writable\\cache/",
"mode": 416
},
"memcached": {
"host": "127.0.0.1",
"port": 11211,
"weight": 1,
"raw": false
},
"redis": {
"host": "127.0.0.1",
"password": null,
"port": 6379,
"timeout": 0,
"database": 0
},
"validHandlers": {
"dummy": "CodeIgniter\\Cache\\Handlers\\DummyHandler",
"file": "CodeIgniter\\Cache\\Handlers\\FileHandler",
"memcached": "CodeIgniter\\Cache\\Handlers\\MemcachedHandler",
"predis": "CodeIgniter\\Cache\\Handlers\\PredisHandler",
"redis": "CodeIgniter\\Cache\\Handlers\\RedisHandler",
"wincache": "CodeIgniter\\Cache\\Handlers\\WincacheHandler"
}
},
false
]
},
{
"file": "D:\\Server\\ci-attend\\public\\index.php",
"line": 67,
"function": "run",
"class": "CodeIgniter\\CodeIgniter",
"type": "->",
"args": []
}
]
}
here the code what I produce:
return DataTables::use('employees')
->addColumn('employee', function ($data) {
return '-';
})
->addColumn('workgroup', function ($data) {
return '-';
})
->addColumn('actions', function ($data) {
return '<div class="d-grid gap-2 d-sm-block">
<div class="btn btn-primary"><span class="bi bi-card-text"></span></div>
<div class="btn btn-danger"><span class="bi bi-trash"></span></div>
</div>';
})
->rawColumns(['actions'])
->hideColumns(['password'])
->make(true);
And already check this issue the same as what I got in #20 but the version that I use for the library is 3.0.0 and still have issues.
Am using this package in my project and it working perfectly in my CodeIgniter v4.1.4 but after upgrading to v4.1.5 there is now error say 'column not fund'
The issue observe is trying to create the db_prefix multiple times.
ERROR - 2021-11-19 03:10:21 --> Unknown column 'zd_`zd_users.user_username' in 'where clause'
CRITICAL - 2021-11-19 03:10:21 --> Unknown column 'zd_`zd_users.user_username' in 'where clause'
#0 C:\xampp\htdocs\clients\occidoma\vendor\codeigniter4\framework\system\Database\MySQLi\Connection.php(292): mysqli->query('SELECT COUNT(*)...', 0)
#1 C:\xampp\htdocs\clients\occidoma\vendor\codeigniter4\framework\system\Database\BaseConnection.php(670): CodeIgniter\Database\MySQLi\Connection->execute('SELECT COUNT(*)...')
#2 C:\xampp\htdocs\clients\occidoma\vendor\codeigniter4\framework\system\Database\BaseConnection.php(598): CodeIgniter\Database\BaseConnection->simpleQuery('SELECT COUNT(*)...')
#3 C:\xampp\htdocs\clients\occidoma\vendor\codeigniter4\framework\system\Database\BaseBuilder.php(1527): CodeIgniter\Database\BaseConnection->query('SELECT COUNT(*)...', Array, false)
#4 C:\xampp\htdocs\clients\occidoma\vendor\irsyadulibad\codeigniter4-datatables\src\TableProcessor.php(35): CodeIgniter\Database\BaseBuilder->countAllResults(false)
#5 C:\xampp\htdocs\clients\occidoma\vendor\irsyadulibad\codeigniter4-datatables\src\DataTableMethods.php(101): Irsyadulibad\DataTables\TableProcessor->count()
#6 C:\xampp\htdocs\clients\occidoma\vendor\irsyadulibad\codeigniter4-datatables\src\TableProcessor.php(42): Irsyadulibad\DataTables\DataTableMethods->filterRecords()
#7 C:\xampp\htdocs\clients\occidoma\vendor\irsyadulibad\codeigniter4-datatables\src\TableProcessor.php(27): Irsyadulibad\DataTables\TableProcessor->doQuery()
#8 C:\xampp\htdocs\clients\occidoma\app\Controllers\Admin\AccountController.php(332): Irsyadulibad\DataTables\TableProcessor->make()
#9 C:\xampp\htdocs\clients\occidoma\vendor\codeigniter4\framework\system\CodeIgniter.php(824): App\Controllers\Admin\AccountController->ajaxListStaffAccount()
#10 C:\xampp\htdocs\clients\occidoma\vendor\codeigniter4\framework\system\CodeIgniter.php(410): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Admin\AccountController))
#11 C:\xampp\htdocs\clients\occidoma\vendor\codeigniter4\framework\system\CodeIgniter.php(318): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)
#12 C:\xampp\htdocs\clients\occidoma\public\index.php(37): CodeIgniter\CodeIgniter->run()
#13 {main}
How can i fix this please i have fork the repo to reproduce this issue.
DataTables::create(db_connect()->table('user u'))
->join("prestataire p", "p.id_prestataire = u.prestataire_id")
->select("u.*, p.nom as name")
->where('prestataire_id IS NOT NULL')
.....................
I think the select function is ignored, i cann't do a custom select when fields are conflicting.
i have table user{ID, nom, prenom, prestataire_id}
and prestataire{ID, nom}
. I want to select with join but with no chance.
I need help !
in your library documentation
->join('address', 'users.id = address.uid', 'INNER JOIN')
but when i use that code not working properly,
i tried this
->join('address', 'users.id = address.uid', 'INNER ')
->join('address', 'users.id = address.uid', 'LEFT')
PHP code
return DataTables::use('rpp_subscription_transaction')
->join('rpp_users', 'rpp_users.uid = rpp_subscription_transaction.user_id', 'INNER JOIN')
->addColumn('actions', function($data) {
return '';
})
->addColumn('transaction_status_col', function($data) {
$class_active = $data->transaction_status == 'paid'?'badge-success':'badge-danger';
$transaction_status = ucwords($data->transaction_status);
return ''.$transaction_status .'';
})
->rawColumns(['actions', 'transaction_status_col'])
->make(true);
Javascript code
$("#example1").DataTable({
"processing": true,
"serverSide": true,`
"ajax": "",
"responsive": true, "lengthChange": false, "autoWidth": false,
"columns": [
{data: 'name', name: 'name'},
{data: 'date', name: 'Transaction Date'},
{data: 'amount', name: 'Amount'},
{data: 'period_start', name: 'Start'},
{data: 'period_end', name: 'End'},
{data: 'transaction_status_col', name: 'Status', orderable: false },
{data: 'actions', name: 'Actions', orderable: false }
],
"searching": false,
});
I tried this
return DataTables::use('users_mobile')
->select('users_mobile.id, users_mobile.name as user_name, users_mobile.rut, users_mobile.platform, area.name as area_name')
->join('area', 'area.id = users_mobile.area_id')
->hideColumns(['users_mobile.id'])
->rawColumns(['action'])
->make(true);
but when load the page, show me alert error. When I see the php url I see a error, and was this:
mysqli_sql_exception #1052
Column 'name' in where clause is ambiguous
And the code when this happened is in:
VENDORPATH\irsyadulibad\codeigniter4-datatables\src\TableProcessor.php : 35
is there a way to fix this without having to change the column name?
(Sorry for my bad english, is not my language)
return DataTables::use('rpp_users')
->where(['rpp_users.role' => '3'])
->select('rpp_users.name as name,
rpp_users.uid as uid,
rpp_users.created_at as trial_at,
rpp_users.paid_at as paid_at,
rpp_users.expirydate as churned_at')
-> orWhere()
->make(true);
Please let me that how can use orWhere ?
halo gan, kok pencarian nya ga jalan ya ?
Kalau kita search data yg kebetulan didalam tabel join maka kosong alias ga ketemu. Kalau di tabel utama datanya bisa ketemu.
Hallo mas irsyadulibad, saya salah satu pengguna library ci4-datatables anda, sekarang saya dihadapkan dengan query gruop by yang tidak bisa saya elakkan, pertanyaannya bagaimana cara menggunakan fungsi gruop by tersebut di library ini ?
Terima Kasih.
halo mas, saat ini saya menggunakan library mas sebagai development saya.
tetapi saya mengalami kendala, yaitu saat ini saya ingin show transaksi berdasarkan id yang diurut secara "DESC". atau yang tampil pada datatables itu berdasarkan input terakhir menjadi muncul dihalaman pertama.
kalau pada query biasa saya bisa dengan menggunakan db->orderBy() untuk mengurutkan data saya.
tapi kalau ini saya belum menemukan solusi nya.
mungkin mas punya solusi nya??
terimakasih
Kodingan saya untuk select concat yaitu
return DataTables::use('tb_kelas')
->select("id, CONCAT(tingkat, abjad) as kelas")
->addColumn('action', function($data) {
return "<a href=\"" . base_url('Kelas/'. $data->id . "/ubah")."\" class=\"btn btn-sm btn-success mr-1\"><i class=\"fas fa-edit\"></i> Ubah</a>
<a href=\"#\" onclick=\"konfirmasiHapus(" . $data->id .")\" class=\"btn btn-sm btn-danger\"><i class=\"fas fa-trash\"></i> Hapus</a>";
})->rawColumns(['action'])
->make(true);
dan untuk isian columns datatable di halaman frontendnya yaitu id dan kelas
error yang didapatkan
{
"title": "mysqli_sql_exception",
"type": "mysqli_sql_exception",
"code": 500,
"message": "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 5",
"file": "D:\\Project\\Sekolah\\vendor\\codeigniter4\\framework\\system\\Database\\MySQLi\\Connection.php",
"line": 292,
"trace": [
{
"file": "D:\\Project\\Sekolah\\vendor\\codeigniter4\\framework\\system\\Database\\MySQLi\\Connection.php",
"line": 292,
"function": "query",
"class": "mysqli",
"type": "->",
"args": [
"SELECT COUNT(*) AS `numrows`\nFROM `tb_kelas`\nWHERE (\nabjad) LIKE '%%' ESCAPE '!'\n )",
0
]
},
{
"file": "D:\\Project\\Sekolah\\vendor\\codeigniter4\\framework\\system\\Database\\BaseConnection.php",
"line": 670,
"function": "execute",
"class": "CodeIgniter\\Database\\MySQLi\\Connection",
"type": "->",
"args": [
"SELECT COUNT(*) AS `numrows`\nFROM `tb_kelas`\nWHERE (\nabjad) LIKE '%%' ESCAPE '!'\n )"
]
},
{
"file": "D:\\Project\\Sekolah\\vendor\\codeigniter4\\framework\\system\\Database\\BaseConnection.php",
"line": 598,
"function": "simpleQuery",
"class": "CodeIgniter\\Database\\BaseConnection",
"type": "->",
"args": [
"SELECT COUNT(*) AS `numrows`\nFROM `tb_kelas`\nWHERE (\nabjad) LIKE '%%' ESCAPE '!'\n )"
]
},
{
"file": "D:\\Project\\Sekolah\\vendor\\codeigniter4\\framework\\system\\Database\\BaseBuilder.php",
"line": 1527,
"function": "query",
"class": "CodeIgniter\\Database\\BaseConnection",
"type": "->",
"args": [
"SELECT COUNT(*) AS `numrows`\nFROM `tb_kelas`\nWHERE (\nabjad) LIKE :abjad): ESCAPE '!'\n )",
{
"abjad)": [
"%%",
true
]
},
false
]
},
{
"file": "D:\\Project\\Sekolah\\vendor\\irsyadulibad\\codeigniter4-datatables\\src\\TableProcessor.php",
"line": 35,
"function": "countAllResults",
"class": "CodeIgniter\\Database\\BaseBuilder",
"type": "->",
"args": [
false
]
},
{
"file": "D:\\Project\\Sekolah\\vendor\\irsyadulibad\\codeigniter4-datatables\\src\\DataTableMethods.php",
"line": 101,
"function": "count",
"class": "Irsyadulibad\\DataTables\\TableProcessor",
"type": "->",
"args": []
},
{
"file": "D:\\Project\\Sekolah\\vendor\\irsyadulibad\\codeigniter4-datatables\\src\\TableProcessor.php",
"line": 42,
"function": "filterRecords",
"class": "Irsyadulibad\\DataTables\\DataTableMethods",
"type": "->",
"args": []
},
{
"file": "D:\\Project\\Sekolah\\vendor\\irsyadulibad\\codeigniter4-datatables\\src\\TableProcessor.php",
"line": 27,
"function": "doQuery",
"class": "Irsyadulibad\\DataTables\\TableProcessor",
"type": "->",
"args": []
},
{
"file": "D:\\Project\\Sekolah\\app\\Controllers\\KelasController.php",
"line": 32,
"function": "make",
"class": "Irsyadulibad\\DataTables\\TableProcessor",
"type": "->",
"args": [
true
]
},
{
"file": "D:\\Project\\Sekolah\\vendor\\codeigniter4\\framework\\system\\CodeIgniter.php",
"line": 824,
"function": "ajaxList",
"class": "App\\Controllers\\KelasController",
"type": "->",
"args": []
},
{
"file": "D:\\Project\\Sekolah\\vendor\\codeigniter4\\framework\\system\\CodeIgniter.php",
"line": 410,
"function": "runController",
"class": "CodeIgniter\\CodeIgniter",
"type": "->",
"args": [
{
"kelas": {
"pager": null
},
"validation": {}
}
]
},
{
"file": "D:\\Project\\Sekolah\\vendor\\codeigniter4\\framework\\system\\CodeIgniter.php",
"line": 318,
"function": "handleRequest",
"class": "CodeIgniter\\CodeIgniter",
"type": "->",
"args": [
null,
{
"handler": "file",
"backupHandler": "dummy",
"storePath": "D:\\Project\\Sekolah\\writable\\cache/",
"cacheQueryString": false,
"prefix": "",
"ttl": 60,
"reservedCharacters": "{}()/\\@:",
"file": {
"storePath": "D:\\Project\\Sekolah\\writable\\cache/",
"mode": 416
},
"memcached": {
"host": "127.0.0.1",
"port": 11211,
"weight": 1,
"raw": false
},
"redis": {
"host": "127.0.0.1",
"password": null,
"port": 6379,
"timeout": 0,
"database": 0
},
"validHandlers": {
"dummy": "CodeIgniter\\Cache\\Handlers\\DummyHandler",
"file": "CodeIgniter\\Cache\\Handlers\\FileHandler",
"memcached": "CodeIgniter\\Cache\\Handlers\\MemcachedHandler",
"predis": "CodeIgniter\\Cache\\Handlers\\PredisHandler",
"redis": "CodeIgniter\\Cache\\Handlers\\RedisHandler",
"wincache": "CodeIgniter\\Cache\\Handlers\\WincacheHandler"
}
},
false
]
},
{
"file": "D:\\Project\\Sekolah\\public\\index.php",
"line": 37,
"function": "run",
"class": "CodeIgniter\\CodeIgniter",
"type": "->",
"args": []
},
{
"file": "D:\\Project\\Sekolah\\vendor\\codeigniter4\\framework\\system\\Commands\\Server\\rewrite.php",
"line": 43,
"args": [
"D:\\Project\\Sekolah\\public\\index.php"
],
"function": "require_once"
}
]
}
Mohon untuk solusinya
hallo irsya, i tried to group a column, but it not working, but group by inside sub query is working properly, thanks
when searching on joined table not working properly, only parent table found record,
when table a join with table b, i can't find result on table b,
thanks
I am having this error:
ERROR - 2022-03-21 04:54:00 --> You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 7
CRITICAL - 2022-03-21 04:54:00 --> You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 7
#0 C:\xampp\htdocs\clients\wiafrica_ads\wa_codes\vendor\codeigniter4\framework\system\Database\MySQLi\Connection.php(292): mysqli->query('SELECT COUNT(*)...', 0)
#1 C:\xampp\htdocs\clients\wiafrica_ads\wa_codes\vendor\codeigniter4\framework\system\Database\BaseConnection.php(670): CodeIgniter\Database\MySQLi\Connection->execute('SELECT COUNT(*)...')
#2 C:\xampp\htdocs\clients\wiafrica_ads\wa_codes\vendor\codeigniter4\framework\system\Database\BaseConnection.php(598): CodeIgniter\Database\BaseConnection->simpleQuery('SELECT COUNT(*)...')
#3 C:\xampp\htdocs\clients\wiafrica_ads\wa_codes\vendor\codeigniter4\framework\system\Database\BaseBuilder.php(1539): CodeIgniter\Database\BaseConnection->query('SELECT COUNT(*)...', Array, false)
#4 C:\xampp\htdocs\clients\wiafrica_ads\wa_codes\vendor\irsyadulibad\codeigniter4-datatables\src\DataTableAbstract.php(186): CodeIgniter\Database\BaseBuilder->countAllResults(false)
#5 C:\xampp\htdocs\clients\wiafrica_ads\wa_codes\vendor\irsyadulibad\codeigniter4-datatables\src\DataTableAbstract.php(195): Irsyadulibad\DataTables\DataTableAbstract->countTotal()
#6 C:\xampp\htdocs\clients\wiafrica_ads\wa_codes\vendor\irsyadulibad\codeigniter4-datatables\src\QueryDataTable.php(34): Irsyadulibad\DataTables\DataTableAbstract->countFiltered()
#7 C:\xampp\htdocs\clients\wiafrica_ads\wa_codes\vendor\irsyadulibad\codeigniter4-datatables\src\QueryDataTable.php(24): Irsyadulibad\DataTables\QueryDataTable->execQueries()
#8 C:\xampp\htdocs\clients\wiafrica_ads\wa_codes\app\Controllers\Admin\AccountController.php(89): Irsyadulibad\DataTables\QueryDataTable->make(true)
#9 C:\xampp\htdocs\clients\wiafrica_ads\wa_codes\vendor\codeigniter4\framework\system\CodeIgniter.php(832): App\Controllers\Admin\AccountController->manageAccounts('admin')
#10 C:\xampp\htdocs\clients\wiafrica_ads\wa_codes\vendor\codeigniter4\framework\system\CodeIgniter.php(419): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Admin\AccountController))
#11 C:\xampp\htdocs\clients\wiafrica_ads\wa_codes\vendor\codeigniter4\framework\system\CodeIgniter.php(326): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)
#12 C:\xampp\htdocs\clients\wiafrica_ads\wa_codes\public\index.php(37): CodeIgniter\CodeIgniter->run()
#13 C:\xampp\htdocs\clients\wiafrica_ads\wa_codes\vendor\codeigniter4\framework\system\Commands\Server\rewrite.php(43): require_once('C:\\xampp\\htdocs...')
#14 {main}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.