Modify MySQL query or Filter

Modify MySQL query or Filter

impex09impex09 Posts: 45Questions: 20Answers: 0
edited September 2018 in Editor

Hello, I create a new table using Editor/Generator.. so in this case in my site I can see all the records

In the table, all the records stored in my database are shown,
what I need is to put a condition in the query, for example,

Select * from mytabla where status = "new";

how can you add filters or condition the result of the table

Thank you


/* * Editor client script for DB table impex_cat_cotizaciones * Created by http://editor.datatables.net/generator */ (function($){ $(document).ready(function() { var editor = new $.fn.dataTable.Editor( { ajax: 'php/table.ccps_sdi_proyectos.php', table: '#ccps_sdi_proyectos', fields: [ { "label": "p_folio:", "name": "p_folio" }, { "label": "fecha_ini_proyecto:", "name": "fecha_ini_proyecto", "type": "datetime", "format": "DD\/MM\/YY" }, { "label": "fecha_fin_proyecto:", "name": "fecha_fin_proyecto", "type": "datetime", "format": "DD\/MM\/YY" }, { "label": "costo_unitario:", "name": "costo_unitario" }, { "label": "notas:", "name": "notas", "type": "textarea" }, { "label": "p_fechaPago:", "name": "p_fechapago", "type": "datetime", "format": "DD-MM-YY" }, { "label": "p_estatusPago:", "name": "p_estatuspago" }, { "label": "p_idFacturaImpex:", "name": "p_idfacturaimpex" }, { "label": "p_idComprobantePago:", "name": "p_idcomprobantepago" }, { "label": "p_observacionesFacturas:", "name": "p_observacionesfacturas", "type": "textarea" } ] } ); var table = $('#ccps_sdi_proyectos').DataTable( { dom: 'Bfrtip', ajax: 'php/table.ccps_sdi_proyectos.php', columns: [ { "data": "folio" }, { "data": "p_folio" }, { "data": "fecha_ini_proyecto" }, { "data": "fecha_fin_proyecto" }, { "data": "costo_unitario" }, { "data": "notas" }, { "data": "estatus" }, { "data": "p_fechapago" }, { "data": "p_estatuspago" }, { "data": "p_idfacturaimpex" }, { "data": "p_idcomprobantepago" }, { "data": "p_observacionesfacturas" } ], select: true, lengthChange: false, buttons: [ { extend: 'create', editor: editor }, { extend: 'edit', editor: editor }, { extend: 'remove', editor: editor } ] } ); } ); }(jQuery));

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Documentation for how to add a condition to the data retrieved from the database is available here. In this case in the PHP you would add:

    ->where( 'status', 'new' )
    

    Allan

  • impex09impex09 Posts: 45Questions: 20Answers: 0

    Thanks a lot, I dont not why doesnt work with string, if I change the condition
    ->where( 'idCotizacion', '10', '>' )

    Works perfect, but If I change the condition trying filter by text doesnt work,

    do you have any idea?

    regards.

    Alex

This discussion has been closed.