• Resolved delauti

    (@delauti)


    Firstly, awesome Bobby, thank you!! With only a little head scratching I was up and running in no time.

    I believe this is a feature request – I’d like to be able to alter the where clause of a query per url variables. For instance the sql in the add_db_table_editor function might read:

    select * from table where id=$var

    and then on the wordpress page:

    <?php $var=$_GET[“id”]; ?>
    [dbte id=mytable]

    I think I understand why this didn’t work, is there another that would work? Is this a useful feature to you or anyone else? TIA!

    https://www.ads-software.com/plugins/wp-db-table-editor/

Viewing 1 replies (of 1 total)
  • Plugin Author bobbysmith007

    (@bobbysmith007)

    Ok there are a couple approaches for this.

    The first is if you are doing a fairly straightforward filter similar to the filters at the top of the table, you can pass default filters through the query string eg:
    https://yoursite.com/wp-admin/admin.php?page=dbte_table&column_name=filter_value

    The other way to handle this is to construct the db-table-editor instance such that the sql passed into your query is already taking into account the filters eg:

    $sql="SELECT * FROM mytable";
    if(@$_REQUEST['myfilter']){
      $sql.=wpdb->prepare(" WHERE mycolumn like %s",@$_REQUEST['myfilter']);
    }
    add_db_table_editor(Array('sql'=>$sql, table='mytable'));

    Please feel free to ask followups if needed

Viewing 1 replies (of 1 total)
  • The topic ‘Variable queries / where clauses’ is closed to new replies.