Published October 02, 2024 by RIT with 0 comment

cara mengatasi ONLY_FULL_GROUP_BY pada codeigniter 3



Assalamualaikum warohmatullohi wabarokatuh,
Wa alaikum salam warohmatullohi wabarokatuh,

Cara mengatasi SELECT list is not in GROUP BY clause and contains nonaggregated column 'your_db' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by. Pada codeigniter, menurut saya ini terjadi karena beda versi, dan kita harus merubah pengaturan melalui myql nya langsung referensi nya bisa dilihat disini. atau jika anda tidak bisa melakukan perubahan karena tidak bisa akses, anda bisa sisipkan kode berikut kedalam query jika menggunakan php native. Jika menggunakan framework, sisipkan kode ini kedalam model atau kedalam construct controllernya, berikut kode nya :

kode dasar :
$this->db->query('SET SESSION sql_mode = ""');

// ONLY_FULL_GROUP_BY
$this->db->query('SET SESSION sql_mode =
                  REPLACE(REPLACE(REPLACE(
                  @@sql_mode,
                  "ONLY_FULL_GROUP_BY,", ""),
                  ",ONLY_FULL_GROUP_BY", ""),
                  "ONLY_FULL_GROUP_BY", "")');

jika kalian menempatkan kode nya di controller :
<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class YourController extends CI_Controller {

	public function __construct()
	{
		parent::__construct();

		$this->db->query('SET SESSION sql_mode = ""');

		// ONLY_FULL_GROUP_BY
		$this->db->query('SET SESSION sql_mode =
		                  REPLACE(REPLACE(REPLACE(
		                  @@sql_mode,
		                  "ONLY_FULL_GROUP_BY,", ""),
		                  ",ONLY_FULL_GROUP_BY", ""),
		                  "ONLY_FULL_GROUP_BY", "")');
	}

Demikian cara disable ONLY_FULL_GROUP_BY pada codeigniter, jika ada kesulitan mengenai artikel ini, bisa tinggalkan komentar dibawah ini. Terima Kasih

TAG TAGS :
CARA disable ONLY_FULL_GROUP_BY PADA CODEIGNITER | CARA disable ONLY_FULL_GROUP_BY PADA CODEIGNITER | CARA disable ONLY_FULL_GROUP_BY MENGGUNAKAN CODEIGNITER | HOW TO disable ONLY_FULL_GROUP_BY USE CODEIGNITER | HOW TO disable ONLY_FULL_GROUP_BY WITH CODEIGNITER | disable ONLY_FULL_GROUP_BY in CODEIGNITER | disable ONLY_FULL_GROUP_BY on CODEIGNITER langsungkoding.blogspot.com | langsungkoding |


BACA JUGA :
Read More
      edit
Published June 25, 2024 by RIT with 0 comment

CHECKBOX IN PAGINATED DATATABLES



Hello I have problem checkbox in paginated, so I am trying choice and check data in datatables and parse value in input hidden, but in second page choice and check not working. And below this my code for solved problem checkbox in second pagination.
let your_date = your_date;

$(".div_for_dataTables").empty();
$(".id_login").val("");

$.ajax({

    method: "POST",
    url: url_nya+'folder_controller/Contoller/getData',
    data: {date_to_controller : your_date},
    success: function(res) {

        let data_nya  = $.parseJSON(res);
        alert('Data exists', 'success');
         // START TABLE
            let html_code = `<table class="table table-bordered _dataTables">`;
                html_code += `
                            <thead>
                                <tr>
                                <td>No. </td>
                                <td>Name</td>
                                <td>Option</td>
                                </tr>
                            </thead>
                            <tbody>
                            `;

            for (let i = 0; i < data_nya.length; i++) {
                // Add dataTables in here
                html_code += `
                    <tr >
                        <td>`+parseInt(1+i)+`</td>
                        <td>`+data_nya[i].name_+`</td>
                                                        <td>
                            <div class="form-check">
                            <input class="form-check-input choice_check" type="checkbox" id_login="`+data_nya[i].id_login+`" name_xxx="`+data_nya[i].name_+`" value="">
                            </div>
                        </td>
                    </tr>
                    `;

            } // END FOR
            html_code += `</tbody>`
            html_code += `</table>`;

            $(".div_for_dataTables").append(html_code);

            let tables_ = $('._dataTables').DataTable({
                                     "iDisplayLength": 5,
                                     "lengthMenu": [[5, 10, -1], [5, 10, "All"]]
                                });
            let rows = tables_.rows({ 'search': 'applied' }).nodes();

         // END TABLE

            let array_push = [];
            let array_push_id = [];
            
            $('.choice_check', rows).change(function() {

                let name   = $(this).attr('name_xxx');
                let id_login = $(this).attr('id_login');

                if($(this).is(":checked")) {
                    
                    array_push.push(" [ "+name+" ] ");
                    array_push_id.push(id_login);

                }else{

                    let index_name = array_push.indexOf(" [ "+name+" ] ");
                    let index_id_login = array_push_id.indexOf(id_login);

                    if (index > -1) {

                        array_push.splice(index_name, 1);
                        array_push_id.splice(index_id_login, 1);
                    }
                }

                $(".name_div").text(array_push);
                $("[name='id_login']").val(array_push_id);

            });
    } // END SUCCESS
                
}); // END AJAX 


And in your case, added this below code :
let tables_ = $('._dataTables').DataTable({
                 "iDisplayLength": 5,
                 "lengthMenu": [[5, 10, -1], [5, 10, "All"]]
            });

let rows = tables_.rows({ 'search': 'applied' }).nodes();


And added code rows this code on your function click checkbox :
  $('.choice_check', rows).change(function() {


Enjoy it. ^_^

TAG TAGS :
checkbox in paginated datatable || How to catch values of checkboxes that are paginated with DataTables plugin || checkbox || how to use checkbox in second pagination || DataTables langsungkoding.blogspot.com | langsungkoding |

REFERENCE :
Read More
      edit