Code Monkey home page Code Monkey logo

ci4-datatables's Introduction

GitHub GitHub repo size Hits

ci4-datatables

Server Side Datatables Library for CodeIgniter 4 Framework


Deskripsi

Library untuk membuat Server Side Datatables pada CodeIgniter 4 agar menjadi mudah dan singkat

Persyaratan:

  • Codeigniter 4.x
  • JQuery 3.3 +
  • Datatables 1.10.x

Cara Instalasi:

  • Letakkan file Datatables.php, (pada folder app/Libraries/)

Contoh Sederhana

<?php namespace App\Controllers;

use CodeIgniter\Controller;
use App\Libraries\Datatables;

class Example extends Controller{
  public function datatables(){
    $datatables = new Datatables;
    $datatables->table('users')->select('name, address');
    // Memproduksi query SELECT name, address FROM users;
    echo $datatables->draw();
    // Automatically return json
  }
}

Dokumentasi

  1. Select Tabel
    Memilih table default
$datatables->table('yourTable');
  1. Get All
    Memilih data pada semua kolom untuk ditampilkan $datatables->draw() :
$datatables->draw();
  1. Select Field
    Menampilkan data pada kolom yang dipilih $datatables->select('field1, field2, fieldN') :
$datatables->select('name, address');
  1. Where Clause
    Menampilkan data yang telah ditentukan valuenya pada kolom teretentu $datatables->where(['field' => 'value']) :
$datatables->where(['name' => 'John']);
  1. Join Clause
    Menggabungkan table melalui field dan kondisi yang telah ditentuakn $datatables->join('Table', 'Condition', 'Type[optional]') :
$datatables->join('parents', 'users.id = parents.id_user');
//Anda juga bisa menambahkan type seperti INNER JOIN, LEFT JOIN, dsb
$datatables->join('parents', 'users.id = parents.id_user', 'INNER JOIN');

Catatan

  • Anda juga dapat menambahkan clausa AND WHERE dengan menambahkan elemen array:
$datatables->where(['field1' => 'data1', 'field2' => 'data2', 'fieldN' => 'dataN']);
  • Anda dapat menambahkan header agar data yang ditampilkan dapat dipastikan tipenya adalah JSON (optional) :
header('Content-Type': 'application/json');

Author's Profile:

Github: [https://github.com/irsyadulibad]
Website: [http://irsyadulibad.my.id]
Facebook: [https://facebook.com/irsyadulibad.dev]

ci4-datatables's People

Contributors

irsyadulibad avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.