-
Chandini BAD BOY
  
-
Posts: 61
Threads: 34
Joined: Dec 2014
Reputation:
0
How to send multiple response using codeigniters RESTful Services
Ex :
$this->response($user_regdata);
$this->response($salary_data);
this way is not working only first response send ..
How to send multiple responses... at a time ?
Manikanta
-
LeMec Junior Member
 
-
Posts: 19
Threads: 1
Joined: Oct 2014
Reputation:
2
(01-23-2016, 05:39 AM)Narf Wrote: (01-22-2016, 11:47 PM)Chandini Wrote: (01-22-2016, 06:48 AM)Narf Wrote: You don't, HTTP doesn't work that way.
Then how to send the multiple response at a time ...?
I'll repeat: You don't!
1 request = 1 response, that's how HTTP works. It's not CI's problem, nor something you just don't know how to do. It's just the way it is.
Man...This forum is sometimes very frustrating to average programmers. Experts are playing mind games with us for no reason.
The question is very clear and easily implied:
What is the best way to update info via Rest API when the information is in a master detail relationship?
You have a table that has users and another table that has Salaries for users.
You want to update that info.
How?
-
skunkbad Senior Citizen
    
-
Posts: 1,300
Threads: 63
Joined: Oct 2014
Reputation:
86
01-23-2016, 01:11 PM
(This post was last modified: 01-23-2016, 01:16 PM by skunkbad.)
(01-22-2016, 05:43 AM)Chandini Wrote: How to send multiple response using codeigniters RESTful Services
Ex :
$this->response($user_regdata);
$this->response($salary_data);
this way is not working only first response send ..
How to send multiple responses... at a time ?
Maybe like this instead:
Code: $this->response( array( 'reg_data' => $user_regdata, 'salary_data' => $salary_data ) );
Narf just isn't playing mind tricks with you; you only have one response. If you need to pass back multiple "responses", then you need to put them in an object, array, or some kind of container.
BTW, why do this? Many people are so bent on REST, they can't even get anything done. Especially if you're working with jQuery or other JS AJAX, you could just as easily echo some JSON:
Code: echo json_encode( array( 'reg_data' => $user_regdata, 'salary_data' => $salary_data ) );
... and if you're trying to route requests with REST (because that's all you're really doing), I just think you're wasting your time. It's just an opinion, but remember that you're the one asking questions.
-
LeMec Junior Member
 
-
Posts: 19
Threads: 1
Joined: Oct 2014
Reputation:
2
(01-23-2016, 02:02 PM)Narf Wrote: (01-23-2016, 10:56 AM)LeMec Wrote: (01-23-2016, 05:39 AM)Narf Wrote: (01-22-2016, 11:47 PM)Chandini Wrote: (01-22-2016, 06:48 AM)Narf Wrote: You don't, HTTP doesn't work that way.
Then how to send the multiple response at a time ...?
I'll repeat: You don't!
1 request = 1 response, that's how HTTP works. It's not CI's problem, nor something you just don't know how to do. It's just the way it is.
Man...This forum is sometimes very frustrating to average programmers. Experts are playing mind games with us for no reason.
The question is very clear and easily implied:
What is the best way to update info via Rest API when the information is in a master detail relationship?
You have a table that has users and another table that has Salaries for users.
You want to update that info.
How?
I give direct answers to direct questions.
If you call that mind games, then the frustration will never end. Us "experts" don't have the magic power of knowing what you mean by asking the wrong questions
Indeed the frustration continues...But it will end when one finds another community and a different framework to work with,,,
-
skunkbad Senior Citizen
    
-
Posts: 1,300
Threads: 63
Joined: Oct 2014
Reputation:
86
(01-23-2016, 02:02 PM)Narf Wrote: (01-23-2016, 10:56 AM)LeMec Wrote: (01-23-2016, 05:39 AM)Narf Wrote: (01-22-2016, 11:47 PM)Chandini Wrote: (01-22-2016, 06:48 AM)Narf Wrote: You don't, HTTP doesn't work that way.
Then how to send the multiple response at a time ...?
I'll repeat: You don't!
1 request = 1 response, that's how HTTP works. It's not CI's problem, nor something you just don't know how to do. It's just the way it is.
Man...This forum is sometimes very frustrating to average programmers. Experts are playing mind games with us for no reason.
The question is very clear and easily implied:
What is the best way to update info via Rest API when the information is in a master detail relationship?
You have a table that has users and another table that has Salaries for users.
You want to update that info.
How?
I give direct answers to direct questions.
If you call that mind games, then the frustration will never end. Us "experts" don't have the magic power of knowing what you mean by asking the wrong questions.
I thought you were supposed to be a mind reader? Isn't that why you get paid the big bucks?
|