Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread EWB, PHP and CodeIgniter.
Thu, Feb 16 2017 11:56 PMPermanent Link

Steve Gill

Avatar

I'm using EWB with PHP and the CodeIgniter 3 framework on the backend.

Using the database features of EWB I can retrieve data successfully from the PHP app by returning it as JSON.  However, I am having a problem when EWB has to send parameters.  It seems EWB is using GET, but CodeIgniter is by default set up to use POST.  

This means that the PHP code gets the request fine but it can't read the parameters. There are ways to make CodeIgniter use GET but it GETs a bit messy.  Wink

Is it possible for the database functionality to use POST or does it only use GET?

Am I hitting my head against a POST trying to GET this to work? Smile

= Steve
Fri, Feb 17 2017 7:10 AMPermanent Link

Steve Gill

Avatar

For now I'm using TServerRequest to post the parameters to the PHP code and using TDataset.LoadRows to load the returned JSON data.

= Steve
Mon, Feb 20 2017 4:30 AMPermanent Link

Matthew Jones

Steve Gill wrote:

>   However, I am having a problem when EWB has to send parameters.  It seems EWB is using GET, but CodeIgniter is by default set up to use POST.  

I'd like to pick up on this. Am I right in reading your message as EWB is using GET to "send data" to the server? If so, it really needs to be changed. That is not a good way to do it. I know, I fell over this myself.

The primary issue is outlined here:
http://stackoverflow.com/questions/3477333/what-is-the-difference-between-post-and-get

"GET requests a representation of the specified resource. Note that GET should not be used for operations that cause side-effects, such as using it for taking actions in web applications. One reason for this is that GET may be used arbitrarily by robots or crawlers, which should not need to consider the side effects that a request should cause."

The POST should be used when the client is requesting data changes. Even if all the data is in the parameters of the URL.

I hope I am mis-reading your post...

--

Matthew Jones
Mon, Feb 20 2017 9:24 PMPermanent Link

Raul

Team Elevate Team Elevate

On 2/16/2017 11:56 PM, Steve Gill wrote:
> I'm using EWB with PHP and the CodeIgniter 3 framework on the backend.
> Using the database features of EWB I can retrieve data successfully from the PHP app by returning it as JSON.  However, I am having a problem when EWB has to send parameters.  It seems EWB is using GET, but CodeIgniter is by default set up to use POST.
> This means that the PHP code gets the request fine but it can't read the parameters. There are ways to make CodeIgniter use GET but it GETs a bit messy.  Wink
> Is it possible for the database functionality to use POST or does it only use GET?
> Am I hitting my head against a POST trying to GET this to work? Smile


Steve,

AFAIK EWB uses strictly GET for any "get data" requests  - params are
basically used for filtering (i.e. sql "where") but it's still very much
read only data retrieval operation.

POST is strictly used for actual data update - dataset transactions.

This usage is pretty normal for rest style APIs.

There can be some value in using post (larger params and not getting
logged on server) but then you lose ability to use same api URL for
multiple operations which would be a major drawback IMHO.

Raul



Mon, Feb 20 2017 9:26 PMPermanent Link

Raul

Team Elevate Team Elevate

On 2/20/2017 4:30 AM, Matthew Jones wrote:

> I'd like to pick up on this. Am I right in reading your message as EWB is using GET to "send data" to the server? If so, it really needs to be changed. That is not a good way to do it. I know, I fell over this myself.

"Send data" only in terms of "these are param values you should use for
query" - result is still  read-only query to retrun some data to EWB app.

> "GET requests a representation of the specified resource. Note that GET should not be used for operations that cause side-effects, such as using it for taking actions in web applications. One reason for this is that GET may be used arbitrarily by robots or crawlers, which should not need to consider the side effects that a request should cause."

Not a concern here IMHO.

> The POST should be used when the client is requesting data changes. Even if all the data is in the parameters of the URL.

EWB does use POST for insert/update/delete (i.e. transactions).

Raul
Mon, Feb 20 2017 10:26 PMPermanent Link

Steve Gill

Avatar

Hi Raul,

<< AFAIK EWB uses strictly GET for any "get data" requests  - params are
basically used for filtering (i.e. sql "where") but it's still very much
read only data retrieval operation.

POST is strictly used for actual data update - dataset transactions.

This usage is pretty normal for rest style APIs.

There can be some value in using post (larger params and not getting
logged on server) but then you lose ability to use same api URL for
multiple operations which would be a major drawback IMHO. >>

Got it. Thanks.

= Steve
Tue, Feb 21 2017 4:01 AMPermanent Link

Matthew Jones

Raul wrote:

> "Send data" only in terms of "these are param values you should use for query" - result is still  read-only query to retrun some data to EWB app.

Phew, would have been surprised any other way. Just your problem then. 8-)

--

Matthew Jones
Image