Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Datatable子行问题,搜索框SQLSTATE[42S22]错误_Javascript_Database_Laravel_Datatables_Datatables 1.10 - Fatal编程技术网

Javascript Datatable子行问题,搜索框SQLSTATE[42S22]错误

Javascript Datatable子行问题,搜索框SQLSTATE[42S22]错误,javascript,database,laravel,datatables,datatables-1.10,Javascript,Database,Laravel,Datatables,Datatables 1.10,我对数据表子行有问题。当使用搜索框搜索时,我抛出以下错误。 主要问题是我何时要执行搜索。 我通过服务器端函数发送数据,因为该表几乎有500万条记录 数据由ajax以json文件的形式发送。 我和拉威尔一起工作 这是数据表代码 <script> function format ( d ) { // `d` is the original data object for the row return '<table cellpadding="5" cellspac

我对数据表子行有问题。当使用搜索框搜索时,我抛出以下错误。 主要问题是我何时要执行搜索。 我通过服务器端函数发送数据,因为该表几乎有500万条记录

数据由ajax以json文件的形式发送。 我和拉威尔一起工作

这是数据表代码

<script>
function format ( d ) {
    // `d` is the original data object for the row
    return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
        '<tr>'+
            '<td>ID:</td>'+
            '<td>'+d.id+'</td>'+
        '</tr>'+
        '<tr>'+
            '<td><b>Dirección</b></td>'+
            '<td></td>'+
        '</tr>'+
        '<tr>'+
            '<td>Calle:</td>'+
            '<td>'+d.calle+'</td>'+
        '</tr>'+
        '<tr>'+
            '<td>Número:</td>'+
            '<td>'+d.numero+'</td>'+
        '</tr>'+
        '<tr>'+
            '<td>Interior:</td>'+
            '<td>'+d.interior+'</td>'+
        '</tr>'+
        '<tr>'+
            '<td>Código Postal:</td>'+
            '<td>'+d.codigopostal+'</td>'+
        '</tr>'+
        '</table>';
}

$(document).ready(function() {
    var table = $('#laravel_datatable').DataTable( {

        "processing": false,
        "serverSide": true,
        "responsive": true,
        "cache": true,
        "ajax": "{{ url('ine.list')}}",

        "language": {url: 'http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json'},
        "scrollY": 400,
        "length" : 5000,
        "deferRender":    true,
        "scroller":       true,
        "columns": [
            {
                "className":      'details-control',
                "orderable":      false,
                "data":           null,
                "defaultContent": ''
            },
            { "data": "nombre" },
            { "data": "apellidopaterno" },
            { "data": "apellidomaterno" },
            { "data": "fechanacimiento" },
            { "data": "actividad","bSortable": false }
        ],
        "order": [[1, 'asc']]
    } );

    // Add event listener for opening and closing details
    $('#laravel_datatable tbody').on('click', 'td.details-control', function () {
        var tr = $(this).closest('tr');
        var row = table.row( tr );

        if ( row.child.isShown() ) {
            // This row is already open - close it
            row.child.hide();
            tr.removeClass('shown');
        }
        else {
            // Open this row
            row.child( format(row.data()) ).show();
            tr.addClass('shown');
        }
    } );
} );


  </script>

There is a small difference that makes the search box work once and throw the error on another.

This is when it works:
JSON文件

"draw": 0,
  "recordsTotal": 500,
  "recordsFiltered": 500,
  "data": [

...

{
      "id": "500",
      "apellidopaterno": "TORRES",
      "apellidomaterno": "ROJAS",
      "nombre": "MAYRA",
      "fechanacimiento": "19820725",
      "actividad": "AMA DE CASA",
      "calle": "C 4 PONIENTE",
      "numero": "506",
      "interior": null,
      "colonia": "BARR SAN ANTONIO",
      "codigopostal": "75120"
    }
  ],
  "input": [

  ]
}
现在抛出错误时

 $ine_puebla = DB::table('ine_puebla')->orderBy('id')->get();


 return datatables()->of($ine_puebla)->make(true);
Now the difference when it does not work at the end of the JSON file is added a query that is the one that conflicts with the search box:
拉威尔控制器

$ine_puebla = DB::table('ine_puebla');


     return datatables()->of($ine_puebla)->make(true);
JSON文件

 "draw": 0,
      "recordsTotal": 500,
      "recordsFiltered": 500,
      "data": [

    ...

    {
          "id": "500",
          "apellidopaterno": "TORRES",
          "apellidomaterno": "ROJAS",
          "nombre": "MAYRA",
          "fechanacimiento": "19820725",
          "actividad": "AMA DE CASA",
          "calle": "C 4 PONIENTE",
          "numero": "506",
          "interior": null,
          "colonia": "BARR SAN ANTONIO",
          "codigopostal": "75120"
        }
      ]

  "queries": [
    {
      "query": "select count(*) as aggregate from (select '1' as `row_count` from `ine_puebla`) count_row_table",
      "bindings": [

      ],
      "time": "0.95"
    },
    {
      "query": "select * from `ine_puebla`",
      "bindings": [

      ],
      "time": "3.96"
    }
  ],
  "input": [

  ]
}

您的表是否有ine_puebla列?它看起来像是laravel侧的问题。在对datatable执行ajax调用时,需要准备datatable预期的数据,并且在调用URL('ine.list')以获取数据时,还要仔细查看datatable发送的查询参数-首先从查询参数和laravel端的do查询中获取搜索到的文本,并准确返回datatable expect。
ine_puebla
是表名,我通过ajax发送json文件。Laravel的发送方式是
returndatatables()->elount(BuscatuIne::query())->toJson()通过服务器端执行此操作的文档使用以下包:[link]()