Grazie Badaze, sto notando che ultimamente posto qui più per il panico che mi prende che per effettiva mancanza di capacità risolutiva.
Credo di aver risolto.
ho impostato due controlli, uno preliminare e uno post analisi del contenuto per aperta/chiusa parentesi:
Codice PHP:
public function OpenParentesi ($prev_andor,$andor, $next_andor){
if ($prev_andor != 'or' && $andor == 'OR') {
$this->query1[] = '(';
}
elseif ($prev_andor == 'or' && ($andor == 'or' || $andor != 'or')) {
$this->query1[] = '';
}
}
public function CloseParentesi($prev_andor, $andor, $next_andor) {
if ($prev_andor == 'or' && $andor != 'or' ) {
$this->query1[] = ')'; }
elseif ($prev_andor == 'or' && andor == 'or') {
$this->query1[] = '';
}
}
Devo puntualizzare forse meglio le condizioni, visto che se andiamo su 3 OR qualcosa potrebbe andar storto, ma di fatto ora il form apre e chiude le parentesi di almeno 2 clausole OR in maniera perfetta.
Per rispondere alla tua domanda, il form (in forma stringata, ci sono optgroup e option in mezzo ovviamente) è così:
Codice PHP:
<select>VOCE</select> <select>UGUALE A/ MINORE DI /*etc.etc */</select> <input type text> <select>VUOTO/AND/OR</select>
P.S ho modificato anche la struttura per registrare tutti gli step della query in $this->query1.
Cosicchè $query finale da infilare in mysqli sarà:
Codice PHP:
$query = implode(" ", $this->query1);
e tutto è mooooolto più coerente.