Re: 2 Gwoo: Zeroes as named and unnamed parameters. Continuation of discussion ot ticket 4917

2008-06-15 Thread AD7six



On Jun 15, 8:30 am, Serge Rodovnichenko <[EMAIL PROTECTED]> wrote:
> OK. Zero cannot be an unnamed parameter like this: /mycontroller/index/
> 0, it's a feature. But this the test below fails too:
>
> $result = Router::url(array('controller'=>'mycontroller',
> 'action'=>'index', 'id'=>0));

> $expected = '/mycontroller/index/id:0';
> $this->assertEqual($result, $expected);
>
> So, 'id' parameter cannot be with zero value at all?
How is it useful to allow that.

> I bother with
> this because I want to make a root nodes in TreeBehaviour with null or
> zero values of parent_id field.

Rather trivial to 'fix', no?

If you are just using named params:
if (!isset($this->params['id'])) {
 $parent_id = 0;
} else {
 $parent_id = $this->params['id'];
}

If you are using the "pass" functionality of the router, or normal
params

function index($parent_id = 0) {
 ...
}
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



2 Gwoo: Zeroes as named and unnamed parameters. Continuation of discussion ot ticket 4917

2008-06-14 Thread Serge Rodovnichenko

OK. Zero cannot be an unnamed parameter like this: /mycontroller/index/
0, it's a feature. But this the test below fails too:

$result = Router::url(array('controller'=>'mycontroller',
'action'=>'index', 'id'=>0));
$expected = '/mycontroller/index/id:0';
$this->assertEqual($result, $expected);

So, 'id' parameter cannot be with zero value at all? I bother with
this because I want to make a root nodes in TreeBehaviour with null or
zero values of parent_id field.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---