Friday, March 27, 2009

Array Help

I am trying to update a Profile by using a slug that was created and
saved in the User table. What I need to do is get the Profile.id using
the $slug that is in User.slug

In the controller:

This is in the profiles_controller

var $uses = array('Profile', 'User');

function update_languages($slug = null)
{
if ($this->RequestHandler->isAjax()) {
$this->set('language', $this->User->findBySlug($slug));
if (!empty($this->data)) {
if ($this->Profile->save($this->data)) {
$this->view_profiles($slug);
}
}
$languages = $this->Profile->Language->find('list', array
('fields' => 'name', 'order' => 'name ASC'));
$this->set(compact('languages'));
}
if (empty($this->data)) {
$this->data = $this->User->findBySlug($slug);
}
}


I managed to get the info from the array:

Array
(
[User] => Array
(
[id] => 3
[group_id] => 3
[username] => dave
[password] =>
[email] =>
[slug] => davetest
[confirmed] => 1
[confirm_code] => 49cc5013-0380-4086-bd30-448c4adcd75b
[created] => 2009-03-26 22:03:31
[modified] => 2009-03-26 22:03:31
)

[Group] => Array
(
[id] => 3
[name] =>
[created] => 2009-03-26 22:02:30
[modified] => 2009-03-26 22:02:30
)


[Profile] => Array
(
[id] => 1
[user_id] => 3
[rank_id] =>
[searchable] => 0
[firstname] => dave
[lastname] => test
)

)


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

No comments: