Hello everyone and sorry for my ignorance, but I'm wasting an afternoon without finding anything to help me. I managed to link a table on the db in CF7 and following the videos on youtube to create with connectivity the list of fields in the table except the json data part:
In the "Table List" I cannot find the suitable formula to report in the Patch field to connect the json array {"1": "Roberto", "2": "Venturae", "8": "Via Torino", " 9 ":" 3273333333 ...)
How to do?
Grazie
Hi
To create a field to receive a json array in a SQL table, you have just to create a field in Text format.
If you have an array like
1=>Roberto
2=>Venturae
8=>Torino
You have to save this field like {data.join[,]:array_var_name}
You can explode this field like {data.split[,]:table_field_name}.
Then I take advantage of your patience. ;-) I apologize because this is not my main job and my preparation is .... :-(
I read the article you recommended and I understood the logic. If I'm not wrong I should decode the json string:
$ strjson = '{"1": "Eriberto", "2": "Genovese", "8": sia3 "
} ';
$ carrel = json_decode ($ strjson);
echo $ carrel-> 1; (result) // Eriberto
echo $ carrel-> 2; ( " ) //Genoese
echo $ carrel etc.
If this is right and not knowing Connectivity yet,
where do i find the "data field of your form"?
Finally, it is the string: $ carrel-> 1; the one that will be reported in the Path of the Table Columns?
Thanks again
In theory I understand what the procedure is. Basically I have to understand the outline, or how to create the new text field in the "Calessini" table and insert the decoding to create a var ... I know that for a beginner like me it is too complicated ... But it could not be left out this Json from the database ??????
Ps. But, you're Italian?
No, French...
And my english is very bad. I'm not sure that I have fully understand what you want.
... and I'm Italian and I speak English worse than you. 😛🤣🤣. The good news is that I am learning things that may come in handy in the future😉
Ok, let's try to understand if we are talking about the same thing.
I have created a measurement form that the customer sends me. It works perfectly and I see it from the "Log" link in the forms menu:
Now I want to create the Report of all the modules received, so I use Connectivity
I create the form following the tutorial on youtube: https://www.youtube.com/watch?v=raXqQcU_OB8&list=PLNdPw6Bog3zcuSKs7NGNi8QPtfj5IsxQA&index=10
and everything works until, in the database, it has to read the "data" field where the Json string is.
As you already wrote, I have to decode the Json string and convert it to "var" and report every "var" in every "Path" of the "Table Colums" Okay?
And now the problem: having the Connectivity form in use (which I know very little) in which section and / or field should I report the code that explodes the Json string?
I hope I was clear and I trust in your patience ...
OK. This is what I understood...
Excuse me but I made myself ill. I have to make a report that gives me the list of forms compiled by customers. For this I am using Connectivity. The initial form filled in by the customer is stored in the database with the fields we talked about including the "date" field with the JSON string. With the Connectivity form I have to take that data and make a report. Everything works with the first single fields (see photos) in the 1st Path I insert "AID" which is the name of the column and in the report it gives me the id n. 1, in the 2nd Path I write "created" and in the report it reports the date of creation of the form, in the 3rd Path I write "ipaddress" and in the report it reports the IP of the customer. The problem is what should I write in the 4th Path to have, in the report, the name "Eriberto" (which is part of the Json string)?
I understand the system for decoding the Json string. The simple problem is where do I have to write the formulas in Connectivity to make them work ?.
Optimal.
Now it remains for me to understand where to insert the decoding code of the json string. (in which area of Connectivity)
Hi Colnem,
I know I'm getting unbearable ....
The code is clear to me and I thank you. The problem is where to apply it.
When you write:
"Then you have to use this var in a TableView field
View Table List:
Data Sources... ecc
I use the Table List in the Views Section of Connectivity.
but what I would like to understand is
where to write the code "$ strjson = $ this-> get (" read_data.model.json_field "," ");"
In which section and in which field of connectivity should I write it?
always in the Table list? (I do not think so)
Thank you
You have to add a PHP Action inTop Menu/Repo/Action...
In your PHP Action, copy this:
//I Suppose your read Data Base is named read_data_8, with Model named Model8
$tmp=json_decode($this->get("read_data_8.Model8.json",""));
echo "<h4> </h4><h4><strong>Json field:</strong> ".'{"1":"Eriberto","2":"Genovese","8":"sia3"}'."</h4>";
echo "<h4><strong>Json_decode:</strong></h4>";
print_r($tmp);
/*Ajout d'un modèle*/
$myvar=array(); $i=0; $id=$this->get("read_data_8.Model8.id","");
foreach ($tmp as $value => $option) {
$myvar[$i]['model']['id']=$id;
$myvar[$i]['model']['value']=$value;
$myvar[$i]['model']['option']=$option;$i++;
};
echo "<h4> </h4><h4><strong>Variable myvar:</strong> </h4>";
print_r($myvar);
/*retour vers CF7*/
$this->set("myvar",$myvar);