Forums

Get array of one field's values from read data action

healyhatman 19 Aug, 2018
3 Likes
I'm annoyed that I just worked this out, since I've made a whole bunch of forms and connections where I've used a PHP action to make an array, and I needn't have bothered.

Let's say you use a read data action to get all of the articles on your site, and you want an array of just the article id's . Maybe your read data action gets all the articles after a certain date, and you want a second read data action to get all the articles NOT in the first read data action.
{var:read_data#.[n].model.field}

===============================================
Array
(
    [read_data29] => Array
        (
            [log] => Array
                (
                    [0] => SELECT `user`.`id` AS `user.id` FROM `##_users` AS `user` LIMIT 100;
                )

            [var] => Array
                (
                    [0] => Array
                        (
                            [user] => Array
                                (
                                    [id] => 558
                                )

                        )

                    [1] => Array
                        (
                            [user] => Array
                                (
                                    [id] => 559
                                )

                        )

                )

        )

)

Using {var:read_data29.[n].user.id} gives me ["558","559"]
Crams 21 Aug, 2018
This is awesome, you made my day! how did you get to the [n] parameter? do you know if there's a way to use a wildcard or a variable?
healyhatman 21 Aug, 2018
I got it from this post
https://www.chronoengine.com/forums/posts/t105619/p377969/chart-widget-how-to-calculate?startat=0

I had never seen it before, haven't seen it since, didn't see it in any of the FAQs or manuals.
webbusteruk 18 May, 2020
Can I just say this is absolutely perfect! We'd never have figured out how to do this ourselves.
This topic is locked and no more replies can be posted.