Hi,
I have an array created in On Load, I would want mix this array in DB read->condition.
I tried in these 3 ways, with out results 😢 😢 😢 😢 :
Debug array in frontend joomla
If I use only 'prog.id_scuola' => $form->data['scuola'], work it
Regards,
Domenico
I have an array created in On Load, I would want mix this array in DB read->condition.
I tried in these 3 ways, with out results 😢 😢 😢 😢 :
<?php
$var = JRequest::getVar('a','', 'get', 'array');
return array (":prog.id_scuola => $form->data['scuola'] AND prog.uniq_id = {$var}");
?>
<?php
return array (":prog.id_scuola => $form->data['scuola'] AND prog.uniq_id => $form->data['a']");
?>
<?php
$form->data['q'] = array();
$form->data['q'] = JRequest::getVar('a','', 'get', 'array');
return array ('prog.id_scuola' => $form->data['scuola'], 'prog.uniq_id' => $form->data['q']);
?>
Debug array in frontend joomla
[a] => Array
(
[0] => b96415f8185c9e13bc768c7eba297caa30927a64
[1] => fb69273dcd0ebc7fc4296c1734f9120011b9273b
)
If I use only 'prog.id_scuola' => $form->data['scuola'], work it
Regards,
Domenico
Hi,
I tried in this way:
Create DB READ in On Load.
Multi read e model-id Enabled
Model-id: ref
Fields: id_viag
Debug:
I don't know why... If I use, in DB Read Conditions on ajax event,
<?php
return array ('prog.uniq_id' => $form->data['ref']['id_viag']);
?>
OR
<?php
return array ('prog.uniq_id' => $form->data['a']);
?>
it doesn't work... Why???
Regards,
Domenico
I tried in this way:
Create DB READ in On Load.
Multi read e model-id Enabled
Model-id: ref
Fields: id_viag
Debug:
[ref] => Array
(
[0] => Array
(
[id_viag] => b96415f8185c9e13bc768c7eba297caa30927a64
)
[1] => Array
(
[id_viag] => fb69273dcd0ebc7fc4296c1734f9120011b9273b
)
)
[a] => Array
(
[0] => b96415f8185c9e13bc768c7eba297caa30927a64
[1] => fb69273dcd0ebc7fc4296c1734f9120011b9273b
)
I don't know why... If I use, in DB Read Conditions on ajax event,
<?php
return array ('prog.uniq_id' => $form->data['ref']['id_viag']);
?>
OR
<?php
return array ('prog.uniq_id' => $form->data['a']);
?>
it doesn't work... Why???
Regards,
Domenico
Hi,
I solved it by creating a Db view... But unfortunately it's not a "perfect" way.
Regards,
Domenico
I solved it by creating a Db view... But unfortunately it's not a "perfect" way.
Regards,
Domenico
Hi Domenico,
I find it hard to understand what you are trying to do here but I suspect that you have some unquoted strings in your query. Does this work?
Bob
I find it hard to understand what you are trying to do here but I suspect that you have some unquoted strings in your query. Does this work?
<?php
return array (":prog.id_scuola => '{$form->data['scuola']}' AND prog.uniq_id = '{$form->data['a']}'");
?>
Bob
Hi Bob,
unfortunately doesn't work your solution.
I try to explain the situation:
I've 2 dropdown connected with ajax
On load
On ajax
Debug
Regards,
Domenico
unfortunately doesn't work your solution.
I try to explain the situation:
I've 2 dropdown connected with ajax
1st field id/name: scuola
Dynamic Data: scuole
Value key: uniq_id
Text key: nome
Events: On != (empty) Set Dynamic Options progetto ajax
2nd field id/name: progetto
Dynamic Data: prog
Value key: uniq_id
Text key: id_cod
On load
DB Read 1
Multi read and Enabled ID: Yes
Model ID: ref
Fields: id_viag
Conditions: <?php $user =& JFactory::getUser(); return array('ref.nome' => $user->name); ?>
DB Read 2
Multi read and Enabled ID: Yes
Model ID: viag
Fields: id_scuola
Conditions: <?php $b=0;
$form->data['a'] = array();
$form->data['a'][$b] = array();
foreach ($form->data['ref'] as $v) { $form->data['a'][$b] = $v['id_viag']; $b++; }
return array('viag.uniq_id' => $form->data['a']); ?>
DB Read 3
Multi read and Enabled ID: Yes
Model ID: scuole
Fields: uniq_id,nome
Conditions: <?php $d=0;
$form->data['c'] = array();
$form->data['c'][$d] = array();
foreach ($form->data['viag'] as $v) { $form->data['c'][$d] = $v['id_scuola']; $d++; }
return array('scuole.uniq_id' => $form->data['c']); ?>
On ajax
DB read ajax
Multi read and Enabled ID: Yes
Model ID: prog
Fields: id_uniq_id,id,cod,id_scuola
Conditions: <?php return array (":prog.id_scuola => '{$form->data['scuola']}' AND prog.uniq_id => '{$form->data['a']}'"); ?>
Custom code
<?php
$results = array();
$results[] = '';
foreach ($form->data['prog'] as $v) {
$results[$v['id_cod']] = $v['id_cod'];
}
echo json_encode($results);
?>
Debug
Debug Array
[ref] => Array
(
[0] => Array
(
[id_viag] => b96415f8185c9e13bc768c7eba297caa30927a64
)
[1] => Array
(
[id_viag] => fb69273dcd0ebc7fc4296c1734f9120011b9273b
)
)
[a] => Array
(
[0] => b96415f8185c9e13bc768c7eba297caa30927a64
[1] => fb69273dcd0ebc7fc4296c1734f9120011b9273b
)
[viag] => Array
(
[0] => Array
(
[id_scuola] => 9058a6c7761d5ea6893d71f9e852fdc22efc19f9
)
[1] => Array
(
[id_scuola] => 1fbb41ac48e8556be45884ed1ec1a0846804d466
)
)
[c] => Array
(
[0] => 9058a6c7761d5ea6893d71f9e852fdc22efc19f9
[1] => 1fbb41ac48e8556be45884ed1ec1a0846804d466
)
[scuole] => Array
(
[0] => Array
(
[uniq_id] => 1fbb41ac48e8556be45884ed1ec1a0846804d466
[nome] => qwerty
)
[1] => Array
(
[uniq_id] => 9058a6c7761d5ea6893d71f9e852fdc22efc19f9
[nome] => asdfg
)
)
)
Regards,
Domenico
This topic is locked and no more replies can be posted.