OptionsConnector or filters aren't working

Hi,
I asked this question in grid column , but nothing answered . So I’m repeating this question here. The problem with complex query . Mine query :

SELECT a.grupe as grupe,a.eile as eile,a.op_nr as op_nr,b.pav_lt as pav_lt,b.opr_laik as opr_laik,b.irengin as irengin,a.padal as padal,a.opr_grupe as opr_grupe,a.kontr_opr as kontr_opr,a.skaid as skaid FROM gam_opr a INNER JOIN opr b ON a.op_nr=b.op_nr and b.db=‘ut’ WHERE ( a.model=‘020-605’ and a.db=‘ut’) LIMIT 0,200

php source :

<?php
require_once( "config.php" );
require( "php/codebase/grid_connector.php" );
require( "php/codebase/db_mysqli.php" );

$slc_tbl = $_GET[ 'tbl' ];
$slc_fld = $_GET[ 'fld' ];
$slc_qry = $_GET[ 'qry' ];
$kalba   = $_GET[ 'k_l' ];
$slc_db  = $_GET[ 'd_b' ];
$slc_mod = $_GET[ 'mdl' ];
$slc_fl2 = $_GET[ 'sl2' ];

$link    = new mysqli( $myServ, $myUser, $myPasw, $myDb );
if ( $link->connect_errno )
   die( 'Prisijungimo klaida : (' . $link->connect_errno . ') ' . $link->connect_error );

$grid = new GridConnector( $link, "MySQLi" );
$grid->dynamic_loading( 200 );
$grid->enable_log( "temp.log", true );      

   $slct1 = new OptionsConnector( $link, "MySQLi" );
   $slct1->render_sql( "select opr_grupe as value, opr_grupe as label from opr_grupes where db = '".$slc_db."' order by opr_grupe asc", "opr_grupe", "opr_grupe(value),opr_grupe(label)" );
   $grid->set_options( "a.opr_grupe(opr_grupe)", $slct1 );
   //$grid->set_options( "opr_grupe", $slct1 ); // previuos version ...

   $slct2 = new OptionsConnector( $link, "MySQLi" );
   $slct2->render_sql( "select padal as value, padal as label from padal where db = '".$slc_db."' order by padal asc", "padal", "padal(value),padal(label)" );
   $grid->set_options( "a.padal(padal)", $slct2 );
   //$grid->set_options( "padal", $slct2 ); // previuos version ...

   $slct3 = new OptionsConnector( $link, "MySQLi" );
   $slct3->render_sql( "select opr_kontr as value, opr_kontr as label from opr_kontr where db = '".$slc_db."' order by opr_kontr asc ", "opr_kontr", "opr_kontr(value),opr_kontr(label)" );
   $grid->set_options( "a.kontr_opr(kontr_opr)", $slct3 );
   //$grid->set_options( "kontr_opr", $slct3 );  // previuos version ...

$grid->render_sql( $slc_qry, "rec_id", $slc_fl2 );
?>

The first problem was that #connector_select_filter was not working as expected - it returned error " Column: ‘kontr_opr’ in where clause is ambiguous " . But OptionConnector was working , editing colum ( “co” or “coro” type ) it returned all values . Searching through forum I found that : viewtopic.php?f=14&t=11913&p=34130&hilit=in+where+clause+is+ambiguous#p34130

I redid render_sql and now $slc_fl2 look like “a.kontr_opr(kontr_opr)” . Now #connector_select_filter is working fine . But editing column values I’m seeing only values from that model , not all values . Log file say the same - optionConnector isn’t working , it do only simple filtering .

SELECT DISTINCT a.op_nr as value FROM gam_opr a INNER JOIN opr b ON a.op_nr=b.op_nr and b.db=‘ut’ WHERE ( a.model=‘020-605’ and a.db=‘ut’)

SELECT DISTINCT a.padal as value FROM gam_opr a INNER JOIN opr b ON a.op_nr=b.op_nr and b.db=‘ut’ WHERE ( a.model=‘020-605’ and a.db=‘ut’)

SELECT DISTINCT a.opr_grupe as value FROM gam_opr a INNER JOIN opr b ON a.op_nr=b.op_nr and b.db=‘ut’ WHERE ( a.model=‘020-605’ and a.db=‘ut’)

SELECT DISTINCT a.kontr_opr as value FROM gam_opr a INNER JOIN opr b ON a.op_nr=b.op_nr and b.db=‘ut’ WHERE ( a.model=‘020-605’ and a.db=‘ut’)

So the problem is :

  • if to use field list as “a.kontr_opr,…” ( or “kontr_opr” simply ) aren’t working #connector_select_filter and filters ( “ambiguous” error ) ;

  • if to use field list as “a.kontr_opr( kontr_opr ),…” then filters are working fine , but not work OptionConnectors;

    How to solve this problem ? What you can suggest ?

Thanks in advance ! Workin with Suite Pro 3.5 version …

It is expected that you will use just field name as part of set_options

$grid->set_options( "opr_grupe", $slct1 ); $grid->set_options( "padal", $slct2 ); $grid->set_options( "kontr_opr", $slct3 );

In such case grid will execute only query which is defied in render_sql, and I don’t see how it can result in ambiguous column message.
Can you please provide result of log file for the case when only field_names used ?

Hi Stanislav,

I’m attaching logs as you asked . “Temp1.log” is with fields list as usually “op_nr,kontr_opr…” . OptionsConnectors are working , filter return error . “Temp2.log” - fields with complex description “…,a.kontr_opr( kontr_opr ),…” . OptionsConnectors aren’t working, filters works fine .

Reagrds ! :slight_smile:
temp_logs.zip (1.21 KB)

Problem solved Stanislav … :slight_smile: . I tried that :

$grid->set_options( “a.kontr_opr”, $slct3 );

All is working . And OptionsConnectors and filters . Thanks …