Do you have any beforeFind() or afterFind() logic? Behaviors? Do you
have a route pointing to this action? Are you certain that $id is what
you think it is when it is handed to view() method?

function view($id = null)
{
        debug("id is ${id}");
        ...

On Wed, Sep 16, 2009 at 11:50 PM, jburns <jeremybu...@me.com> wrote:
>
> I have a table (sub_account_types) where the view and edit functions
> always return the first row in the database regardless of the id
> actually requested, even if I bake the model, views and controllers.
> Can anyone suggest what might be going astray?
>
> The sql in the debug pane confirms that it is always looking for id
> 1:
> SELECT `SubAccountType`.`id`, `SubAccountType`.`name`,
> `SubAccountType`.`created`, `SubAccountType`.`modified` FROM
> `sub_account_types` AS `SubAccountType` WHERE `SubAccountType`.`id` =
> 1 LIMIT 1
>
> The url shows the right id:
> http://localhost/accounts/sub_account_types/view/4
>
> The baked view/edit functions look fine:
>        function view($id = null) {
>                if (! $id) {
>                        $this->flash(__('Invalid SubAccountType', true), array
> ('action'=>'index'));
>                }
>                $this->set('subAccountType', $this->SubAccountType->read(null,
> $id));
>        }
>
> The baked models and controllers are standard and look normal too.
>
> Even if I hard code a specific $id in the view finction, it still
> tries to find $id = 1.
>
> If I delete the row in the database where id = 1, the view displays
> correctly with empty fields (in other words it does not complain that
> the row does not exist).
> >
>

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

Reply via email to