Hi, friends
Is it possible to specify which fields I need to be taken from the table in Read Data in the CF7?
I mean something like "Fields to retrieve" in CF6.
Thanks
Is it possible to specify which fields I need to be taken from the table in Read Data in the CF7?
I mean something like "Fields to retrieve" in CF6.
Thanks
I was looking for this too and couldn't find it. I was trying to have an email sent to an email address found by a "Read data". In my scenario I had the read data take all the fields in the table and then in the "Recipient's list" of the email I narrowed it down to just the email address {var:read_data_48.0.Model48.EmailAddress}.
For me the trick was to look at the debug data and see how the arrays were laid out. If you'll notice there was a "0" I had to put into the variable tag, wasn't expecting that.
It would be nice to just know how to isolate one field with the read data however. Hope this helps someone. Realize it's not really exactly on topic based on the post heading.
For me the trick was to look at the debug data and see how the arrays were laid out. If you'll notice there was a "0" I had to put into the variable tag, wasn't expecting that.
It would be nice to just know how to isolate one field with the read data however. Hope this helps someone. Realize it's not really exactly on topic based on the post heading.
[read_data_48] => Array
(
[result] => Data read successfully!
[log] => Array
(
[0] => SELECT `Model48`.`EMPId` AS `Model48.EMPId`, `Model48`.`PropID` AS `Model48.PropID`, `Model48`.`FirstName` AS `Model48.FirstName`, `Model48`.`LastName` AS `Model48.LastName`, `Model48`.`MiddleInitial` AS `Model48.MiddleInitial`, `Model48`.`FullName` AS `Model48.FullName`, `Model48`.`Suffix` AS `Model48.Suffix`, `Model48`.`HireDate` AS `Model48.HireDate`, `Model48`.`Active` AS `Model48.Active`, `Model48`.`JobTitle` AS `Model48.JobTitle`, `Model48`.`Department` AS `Model48.Department`, `Model48`.`DateAdded_OrShouldHaveBeenAdded` AS `Model48.DateAdded_OrShouldHaveBeenAdded`, `Model48`.`EndDate` AS `Model48.EndDate`, `Model48`.`EmailAddress` AS `Model48.EmailAddress` FROM `tblemployee` AS `Model48` WHERE `Model48`.`EMPId` IN ('886');
)
[var] => Array
(
[0] => Array
(
[Model48] => Array
(
[EMPId] => 886
[PropID] => 02
[FirstName] => Jack
[LastName] =>
[MiddleInitial] =>
[FullName] => , Jack
[Suffix] =>
[HireDate] => 2011-08-17 00:00:00
[JobTitle] => Director
[Department] => NULL
[DateAdded_OrShouldHaveBeenAdded] => 5/15/2013 11:10:11 AM
[EndDate] => NULL
[EmailAddress] => nonofyourbusinesssat@gmail.com
)
Is it possible to specify which fields I need to be taken from the table in Read Data in the CF7?
No, it is impossible. CF7 is not fully finished...
If you want, you have to use a SQL action, but it returns an array without model, difficult to use in a checboxes views, for example.
So you have to rebuild result to add a model.
An exemple, using a personal table named -parametres
SQL Element named sql_data_6
SELECT id, field1 FROM `-parametres` WHERE field1= '{var:value}';
In succes block of SQL Element, I insert a PHP action named php_10, to add a model at the result:
$tmp=$this->get("sql_data_6", ""); foreach ($tmp as $key => $value) {$tmp[$key]=array('model'=>$value);} return $tmp;
Results:
{var.pr:sql_data_6} (without model):
Array
(
[0] => Array
(
[id] => 2010
[title] => Anglais utile
)
[1] => Array
(
[id] => 2030
[title] => Échecs
)
[2] => Array
(
[id] => 2040
[title] => Informatique
)
)
{var.pr:php_10} (within model):
Array
(
[0] => Array
(
[model] => Array
(
[id] => 2010
[title] => Anglais utile
)
)
[1] => Array
(
[model] => Array
(
[id] => 2030
[title] => Échecs
)
)
[2] => Array
(
[model] => Array
(
[id] => 2040
[title] => Informatique
)
)
)
Ok thank you Colnem. Seems more complicated. I think I'll just leave it the way I have it (pulling all and the isolating with the var tag). Have a great day.
For me the solution of jformicola worked (adding a "0" in the Value of read data var) - thank you so much!
Just realized that it depends of the Select-Field in the "Read Data" Action =>
"First Record" - {var:read_data_xy.Model.Field}
"All Matching Records" - {var:read_data_xy.0.Model.Field}
- because the array is nested with one more level.
"First Record" - {var:read_data_xy.Model.Field}
"All Matching Records" - {var:read_data_xy.0.Model.Field}
- because the array is nested with one more level.
You're welcome pixelhexe, glad it helped you. Have a great day/night.
You need to login to be able to post a reply.