0

I have a method

function checkin($var1){

$newVar1 = $var1;
....
...
}

I am calling it via Restful and I am passing it like this

$url = 'http://mydomain.com/controller/checkin/'.$var1;

Now i want to pass two variables but I am not sure how would it pick the second one I guess I can do this

$url = 'http://mydomain.com/controller/checkin/'.$var1.'/'.$var2;

not sure what would I do on receiving end to make sure it knows what var to use where. thanks

1 Answer 1

2

On the other end, you have to change your action method signature to

function checkin($var1, $var2){
    // (...)
}

Another option is using Cake's named parameters. That would require a change in both the url and the action:

URL

$url = 'http://mydomain.com/controller/checkin/var1:'.$var1.'/var2:'.$var2;

Action method

function checkin(){
    $var1 = $this->params['named']['var1'];
    $var2 = $this->params['named']['var2'];
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.