Re: Documentation on modifying default REST routes

2012-08-10 Thread Mike Griffin
On Fri, Aug 10, 2012 at 9:58 AM, Lightee  wrote:
> Thanks for your patient replies. Yes, I did read it even a few times but
> cannot be sure if I understand correctly. The problem is there is no sample
> code to test one's understanding.
>
>  Router::connect(
> "/:controller/:id",
> array("action" => "edit", "[method]" => "PUT"),
> array("id" => "[0-9]+")
> );
>
> I am guessing that what it means is that the action "edit" uses HTTP PUT and
> the parameter passed in is the id field. id field is a digit. What if I want
> to pass in 2 or more parameters which are not primary keys? May I know if
> this can be done in CakePHP?
>

What have you tried?

You can get more documentation in the API
http://api.cakephp.org/class/router#method-Routerconnect

Mike.

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: Documentation on modifying default REST routes

2012-08-10 Thread Lightee
Thanks for your patient replies. Yes, I did read it even a few times but 
cannot be sure if I understand correctly. The problem is there is no sample 
code to test one's understanding. 

 "edit", "[method]" => "PUT"),
array("id" => "[0-9]+"));

I am guessing that what it means is that the action "edit" uses HTTP PUT 
and the parameter passed in is the id field. id field is a digit. What if I 
want to pass in 2 or more parameters which are not primary keys? May I know 
if this can be done in CakePHP?

Thank you very much.

On Friday, August 10, 2012 4:43:35 PM UTC+8, Mike Griffin wrote:
>
> On Thu, Aug 9, 2012 at 4:38 PM, Lightee > 
> wrote: 
> > What if the wanted data to be returned is based on data fields other 
> than 
> > the id? It is restricting to get data based on id only. Is there some 
> way to 
> > get data based on other fields of the table? 
> > 
>
> Did you look here: 
> http://book.cakephp.org/2.0/en/development/rest.html#custom-rest-routing 
>
> Mike. 
>

On Friday, August 10, 2012 4:43:35 PM UTC+8, Mike Griffin wrote:
>
> On Thu, Aug 9, 2012 at 4:38 PM, Lightee > 
> wrote: 
> > What if the wanted data to be returned is based on data fields other 
> than 
> > the id? It is restricting to get data based on id only. Is there some 
> way to 
> > get data based on other fields of the table? 
> > 
>
> Did you look here: 
> http://book.cakephp.org/2.0/en/development/rest.html#custom-rest-routing 
>
> Mike. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: Documentation on modifying default REST routes

2012-08-10 Thread Mike Griffin
On Thu, Aug 9, 2012 at 4:38 PM, Lightee  wrote:
> What if the wanted data to be returned is based on data fields other than
> the id? It is restricting to get data based on id only. Is there some way to
> get data based on other fields of the table?
>

Did you look here:
http://book.cakephp.org/2.0/en/development/rest.html#custom-rest-routing

Mike.

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: Documentation on modifying default REST routes

2012-08-09 Thread Lightee
What if the wanted data to be returned is based on data fields other than 
the id? It is restricting to get data based on id only. Is there some way 
to get data based on other fields of the table?

The id bit probably means that an id is being sent to the method. A 
> view method needs an id to return the single thing that is being 
> viewed whereas the index doesn't need one as it returns a list of all 
> things. 
>
> The same for each of the other methods. 
>
> Hope this helps. 
> Mike. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: Documentation on modifying default REST routes

2012-08-09 Thread Mike Griffin
On Thu, Aug 9, 2012 at 1:41 PM, Lightee  wrote:
> Dear Cakephp gurus,
>
>  Router::resourceMap(array(
> array('action' => 'index', 'method' => 'GET', 'id' => false),
> array('action' => 'view', 'method' => 'GET', 'id' => true),
> array('action' => 'add', 'method' => 'POST', 'id' => false),
> array('action' => 'edit', 'method' => 'PUT', 'id' => true),
> array('action' => 'delete', 'method' => 'DELETE', 'id' => true),
> array('action' => 'update', 'method' => 'POST', 'id' => true)
> ));
>
> What does 'id'=>false or true means? I cannot find sufficient documentation
> in the API documentation.
>

The id bit probably means that an id is being sent to the method. A
view method needs an id to return the single thing that is being
viewed whereas the index doesn't need one as it returns a list of all
things.

The same for each of the other methods.

Hope this helps.
Mike.

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Documentation on modifying default REST routes

2012-08-09 Thread Lightee
Dear Cakephp gurus,

I am trying to build web services using CakePHP. The default REST routes 
are not suitable for me as add, edit, update, delete are already taken up 
for other purposes. 

I need to modify the default rates. From 
http://book.cakephp.org/2.0/en/development/rest.html,

 'index', 'method' => 'GET', 'id' => false),
array('action' => 'view', 'method' => 'GET', 'id' => true),
array('action' => 'add', 'method' => 'POST', 'id' => false),
array('action' => 'edit', 'method' => 'PUT', 'id' => true),
array('action' => 'delete', 'method' => 'DELETE', 'id' => true),
array('action' => 'update', 'method' => 'POST', 'id' => true)));

What does 'id'=>false or true means? I cannot find sufficient documentation in 
the API documentation. 

I have tried to search everywhere on sample code for CakePHP web services. But 
all I found are 2 links on related documentation
http://book.cakephp.org/2.0/en/development/rest.html
http://book.cakephp.org/2.0/en/views/json-and-xml-views.html

To newbies like me, it is not very helpful although it may be enough for the 
experts. Can someone point me to more links?

Thank you very much.



-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.