I have a form with a checkbox group.
Here is what I see in the database:
select F69 , F70 , F71 , F72 from cms_visforms_6;
Code:
+--------------------------+------------+------------+--------------+
| F69 | F70 | F71 | F72 |
+--------------------------+------------+------------+--------------+
| yves.geunes@aeronomie.be | 2017-07-24 | 2019-07-31 | 11 , 21 , 12 |
+--------------------------+------------+------------+--------------+
I tried to access the data using the joomla API:
Code:
$query="select F69 as mail, F70 as startdate, F71 as enddate, F72 as days from cms_visforms_6 where F69='$mail'";
$db->setQuery($query);
$result = $db->loadAssocList();
error_log(print_r($result,true));
file_put_contents("PARTTIME.TXT",print_r($result,true),FILE_APPEND);
The error_log showed:
Code:
[0] => Array\n (\n [mail] => yves.geunes@aeronomie.be\n [startdate] => 2017-07-24\n [endd
ate] => 2019-07-31\n [days] => 11
The file pARTTIME.TXT showed me:
Code:
[0] => Array
(
[mail] => yves.geunes@aeronomie.be
[startdate] => 2017-07-24
[enddate] => 2019-07-31
[days] => 11
)
When I use mysql CLI I see:
Code:
+--------------------------+------------+------------+--------------+
| mail | startdate | enddate | days |
+--------------------------+------------+------------+--------------+
| yves.geunes@aeronomie.be | 2017-07-24 | 2019-07-31 | 11 , 21 , 12 |
+--------------------------+------------+------------+--------------+
Only when I redirected the output of the mysql command to a file, I found out the truth:
Code:
mail startdate enddate days
yves.geunes@aeronomie.be 2017-07-24 2019-07-31 11\0, 21\0, 12
I understand that a \0 character is used as separator, but it is not very clear, and Joomla stumbled on it. To obtain my data, the query had to be modified to:
Code:
$query="select F69 as mail, F70 as startdate, F71 as enddate, replace(F72,'\0','') as days from cms_visforms_6 where F69='$mail'";