The "IN($myParam)" query will return a result set with all the ids, in multiple rows. Use loadColumn() instead of loadResult(), which returns an array of a single columns values from the result set, and implode that ...
Code:
$contacto_assessor = $db->loadColumn();
return implode(';', $contacto_assessor);
-- hugh
Hi Cheesegrits!!!
The "IN($myParam)" query will return a result set with all the ids, in multiple rows. Use loadColumn() instead of loadResult(), which returns an array of a single columns values from the result set, and implode that ...
Code:
$contacto_assessor = $db->loadColumn();
return implode(';', $contacto_assessor);
-- hugh
Hi Cheesegrits!
I thought that this situation was already resolved, but here is a detail that will not let it work!
When I use this query:
$contactoassessor = "SELECT contacto_ctt FROM tb_contacto WHERE id_contacto_geral_ctt IN($myParam) AND tipo_contacto_ctt = 1 ORDER BY date_time DESC";
$db->setQuery($contactoassessor);
$contacto_assessor = $db->loadColumn();
return "'".implode("', '", $contacto_assessor)."'";
I want to populate a field "ids_das_linhas_selecionadas_sms_grp", with the "contact_ctt" of the ids selected! With the format: ( '+351912643315', ) So far so good, it's working!
The question is I have a php script (form pulgin:
http://prntscr.com/i24b7p), which will read this field to put in an array:
$numbers = [$formModel->getElementData('tb_envio_sms_grupo___ids_das_linhas_selecionadas_sms_grp')];
But this does not work, because it does not assume as an array but a single value (maybe string).
To test I also tried to put the numbers in variable in the field "ids_das_linhas_selecionadas_sms_grp", and it does not work.
$numeros = "'+351912643315', '+351964650705', '+351939795220'";
return $numeros;
However if you put the numbers in the array directly in plugin form (for testing) it works:
$numbers = ['+351912643315', '+351964650705', '+351939795220'];
I assume that by using the field "ids_das_linhas_selecionadas_sms_grp", the variable "$ numbers" takes on a string.
If you put the numbers directly into the form's pulgin, assume the array.
How can I pass the field value "ids_das_linhas_selecionadas_sms_grp", as array for variable $numbers?