DB query/single query $_GET/$_POST variable generation

Just wondering, is there a specific reason why API database query steps don’t auto produce corresponding $_GET/$_POST variables for conditions like the insert and update ones do? The sort/dir variables get added but nothing else.

If it’s just one of those things that was overlooked and everyone is used to, could it be added?

I know I’m the one who does everything different around here, but I’d rather have an option to turn off the existing auto-generation of post variables…if that existed too I’d be happy to vote for this request!

I guess it’s because insert/ update queries can assume it needs all the table fields be created as $_POST variables however how would the query builder know which $_GET fields are to be used in a condition before the condition is set and you cant (via GUI) set the condition without the variable. Are you suggesting it creates all the table fields as $_GETS?

No. I was suggesting that when you add a query any POST or GET variables you add to conditions, they should be auto added. I often create an action file, go to add a query, add the conditions. If the GET isn’t set up, I enter it in code view of the picker but then have to remember to add it to the variable list to be able to use it on the client-side SC component. In my mind, it seems to be a needless extra step to have to add the variable.

Well it is more a chicken and egg problem… to choose any globals in a query like $_GET or $_POST fields they have to exist first. So you have to create them first as we have no idea what you will be using.

In the update or delete query we auto generate those based the database columns if found only.

But they’re added from the condition part of an update, I thought the same could be done for queries

Example of what I mean:
I want to add a single query to an API. If I add the query before manually adding the $_GET variable, I can type in the expression in Query Builder but the associated variable is not created

However, if I do the same in an update:


it is generated
image

What I’m trying to suggest is taking a current two-step process (1. add variable, 2. add to condition in query) and make it one-step for those happy typing the variable name (1. add to condition and variable is created automatically)

An alternative would be having the option to add GET/POST variables from within the data picker

The most annoying effect of the current method is that if you add the query step before adding the GET variable, because it has validation that a query has been added, you have to either remove it, add the variable and try again; or type the variable in and then create the corresponding variable afterwards.

1 Like

bump

@george, @patrick
I don’t know if you noticed, but Jon’s meet-up demo highlighted why this could help:

When Jon added the update and the paged queries, he went to bind conditions to the queries but the relevant GET variables weren’t available because he hadn’t made them first. This meant he had to close the query window, remove the query, add the variable and then go back in and rebuild the query again.

It would be SOOO much more efficient to be able to add variable from within the data picker.

1 Like

I think it would be great if we could pick whether we want to auto create $_POST or $_GET variables, or even no auto create, for insert/update queries. This would save me A LOT of time!!

EDIT: It JUST occurred to me that I can go into code view and just change $_POST to $_GET and voila! LOL! Not ideal, but will save me time for now.