Forums

read data

ernst@volny.cz 16 May, 2023
how do I get it loaded from the database:

i looked at this tutorial but it doesn't work - https://www.chronoengine.com/forums/topics/view/108638/access-table-data

i need data in php but {var:Model.field} or $this->get("Model.field") doesn't work

ernst@volny.cz 16 May, 2023
I need to get to the result of read data (from database ) in action,
I can see the results in debug, but I can't get to them.
something like $this->get('read_data_107.id') or $this->get('Model107.id') doesn't work
vdneut 16 May, 2023
Did you select the Set Models Data behavior in the Data input field of the Read Data action?
ernst@volny.cz 18 May, 2023
yes I have.
In debug I get:
[read_data_164] => Array
(
[result] => Data read successfully!
[log] => Array
(
[0] => SELECT `Model174`.`form_id` AS `Model174.form_id`, `Model174`.`approved` AS `Model174.approved`, `Model174`.`created` AS `Model174.created`, `Model174 `.`modified` AS `Model174.modified`, `Model174`.`ipaddress` AS `Model174.ipaddress`, `Model174`.`page` AS `Model174.page`, `Model174`.`data` AS `Model174 .data`, `Model174`.`name` AS `Model174.name`, `Model174`.`email` AS `Model174.email`, `Model174`.`phone` AS `Model174.phone`, `Model174`. `right' AS `Model174.right', `Model174`.`count_of_pieces' AS ``Model174.count_of_pieces'', `Model174`.`select' AS `Model174.select', `Model174`.`need' AS `Model174.need' `, `Model174`.`thermo` AS `Model174.thermo`, `Model174`.`number_of_pieces1` AS ``Model174.number_of_pieces1`, `Model174`.`files1` AS `Model174.files1`, `Model174`.`print options ` AS `Model174.print options`, `Model174`.`print` AS `Model174.print`, `Model174`.`ordering` AS `Model174.ordering`, `Model174`.`state` AS `Model174.state`, AS `Model174.post_name`, `Model174`.`address` AS `Model174.address`, `Model174`.`termin` AS `Model174.termin`, `Model174`.`id` AS `Model174.id` FROM `g5pw9_chronog3_dataform ` AS `Model174` LIMIT 1;
)

[var] => Array
(
[Model174] => Array
(
[form_id] => order-form
[approved] => 1
[created] => 2023-05-18 12:43:58
[modified] => 2023-05-18 12:43:58
[ipaddress] => 89.177.186.11
[page] => 1
[data] => data
[name] => Miroslav Ernst
[email] => ernst@volny.cz
[phone] =>
[right] =>
[count_of_kusup] => 1
[select] => 1
[need] =>
[thermo] =>
[number_of_pieces1] => 1
[files1] => none
[print options] => 1
[print] => 1
[state] => 1
[price] => 850
[published] => 1
[branch] =>
[branch_name] =>
[address] =>
[term] =>
[id] => 154
)

)

)

but how do i find the field value in the table? For example id.

In html and php
Pkoll 18 May, 2023
In the field advanced settings you define “value and placeholder”
Then in de field: {var:Model174.id} of {var:read_data_174.Model174.id}.
vdneut 20 May, 2023
As a general approach to find things out how they work, I take a demo form and first try out the ting I want to achieve.
For example, load the Basic Article List example as it is the mother of all CF7 demo's.
Then add a Advanced/PHP element just below a read Action, for example in the 'edit' page and write something like this:

echo "<p>var: ".$this->get("Article.title", "No title")."</p>";
echo "<p>data: ".$this->data("Article.title", "No title")."</p>";

And watch the result. If no result, try adding the Set Models Data behavior in the Data input field of the Read Data action.
Get any result? Compare it with what you have and smooth out any difference until your form works.
In this case the get should give you a result.
You need to login to be able to post a reply.