Forums

Where condition doesn't work

ilmagowalter 19 Feb, 2016
Hi, i'm here again
i have a chronoconnectivity connection that show a list of element
http://www.screencast.com/t/B2RMuk0njkQ
i click on edit and i can edit the records
http://www.screencast.com/t/KJTiB0ODgvc
i load dropdown with data from other table with dbread
all work fine

now i wont to load data in dropdown of edit form, filtering by some criteria
i want to filter ecbox dropdown with this condition

<?php
return array (":DropdownEcoBOX.ID_ECOBOX not in ( select id_ecobox from ecopm_sede_installazione) or DropdownEcoBOX.ID_ECOBOX = " . $form->data['ID_ECOBOX']);
?>


i receive the error
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 SQL=SELECT `DropdownEcoBOX`.`ID_ECOBOX` AS `DropdownEcoBOX.ID_ECOBOX`, `DropdownEcoBOX`.`NUM_SERIE` AS `DropdownEcoBOX.NUM_SERIE` FROM `ecopm_anag_ecobox` AS `DropdownEcoBOX` WHERE DropdownEcoBOX.ID_ECOBOX not in ( select id_ecobox from ecopm_sede_installazione) or DropdownEcoBOX.ID_ECOBOX = 

like if $form->data['ID_ECOBOX'] is empty but if i put debugger i can see
    [Data] => Array
        (
            [ID_SEDE] => 1
            [ID_CLIENTE] => 1
            [DESCRIZIONE] => Piano primo, sala ristoro
            [STATO] => Italia
            [PROVINCIA] => Palermo
            [COMUNE] => Palermo
            [INDIRIZZO] => via le mani dal naso installato
            [NUM_CIVICO] => 15
            [ID_ECOBOX] => 1
            [ID_DISPOSITIVO] => 1
        )

and
    [SedeInstallazione] => Array
        (
            [ID_SEDE] => 1
            [ID_CLIENTE] => 1
            [DESCRIZIONE] => Piano primo, sala ristoro
            [STATO] => Italia
            [PROVINCIA] => Palermo
            [COMUNE] => Palermo
            [INDIRIZZO] => via le mani dal naso installato
            [NUM_CIVICO] => 15
            [ID_ECOBOX] => 1
            [ID_DISPOSITIVO] => 1
        )

i tried to use too
$form->SedeInstallazione['ID_ECOBOX']

i think is only sintax problem, can someone help me ?
ilmagowalter 19 Feb, 2016
Solved with

<?php
return array (":DropdownEcoBOX.ID_ECOBOX not in ( select id_ecobox from ecopm_sede_installazione) or DropdownEcoBOX.ID_ECOBOX = " . $form->data['SedeInstallazione']['ID_ECOBOX']);
?>
GreyHead 19 Feb, 2016
Hi ilmagowalter,

I'm not sure if this will work but please try
<?php
return array (":DropdownEcoBOX.ID_ECOBOX not in ( select id_ecobox from ecopm_sede_installazione) or DropdownEcoBOX.ID_ECOBOX = {$form->data['ID_ECOBOX']}" );
?>

Bob
ilmagowalter 19 Feb, 2016
tried but don't works
instead
$form->data['SedeInstallazione']['ID_ECOBOX']
work
i completed the instruction with
<?php
if ( empty($form->data['SedeInstallazione']['ID_ECOBOX']) ) { 
  return array (":DropdownEcoBOX.ID_ECOBOX not in ( select id_ecobox from ecopm_sede_installazione)");
} else { 
  return array (":DropdownEcoBOX.ID_ECOBOX not in ( select id_ecobox from ecopm_sede_installazione) or DropdownEcoBOX.ID_ECOBOX = " . $form->data['SedeInstallazione']['ID_ECOBOX']);
}
?>
This topic is locked and no more replies can be posted.