Re: Documentation on modifying default REST routes

2012-08-10 Thread Mike Griffin
On Thu, Aug 9, 2012 at 4:38 PM, Lightee lightai...@gmail.com 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 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. 

?phpRouter::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?

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 light...@gmail.com javascript: 
 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 light...@gmail.com javascript: 
 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 Fri, Aug 10, 2012 at 9:58 AM, Lightee lightai...@gmail.com 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.

 ?php
 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-09 Thread Mike Griffin
On Thu, Aug 9, 2012 at 1:41 PM, Lightee lightai...@gmail.com wrote:
 Dear Cakephp gurus,

 ?php
 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.




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.