Tuesday, April 28, 2009

find vs. read

I am trying to replace a read() with my own find statement.

I am running them both to see the results they produce. The $model_name is
dynamicaly added so i can contain the specific model needed for this specic
function depending on the action)

$this->data = $this->User->read(null, $id);
debug($this->data);

$this->data = $this->User->find('first', array(
'conditions' => array('User.id' =>
$this->Auth->user('id')),
'fields' => array('User.id'),
'contain' => array($model_name)));
debug($this->data);

Now when i use read() the everything works fine but the array is a monster,
if i use find it prodces the slim clean array but it does not work. Basicaly
it just loads a form with the users selected options checked or not checked.
Using the read everything is populated. Using find all the info apears in
the array but the form renders blank.

Any ideas what missing from this?

read debug:
Array
(
[User] => Array
(
[id] => 3
array..........


Way to much to post here

.................
)

[System] => Array
(
[0] => Array
(
[id] => 2
[name] => Windows XP
[UsersSystem] => Array
(
[id] => 135
[user_id] => 3
[system_id] => 2
)

)

[1] => Array
(
[id] => 4
[name] => Windows 2000
[UsersSystem] => Array
(
[id] => 134
[user_id] => 3
[system_id] => 4
)

)

)

)






contain debug;

Array
(
[User] => Array
(
[id] => 3
)

[System] => Array
(
[0] => Array
(
[id] => 2
[name] => Windows XP
[UsersSystem] => Array
(
[id] => 135
[user_id] => 3
[system_id] => 2
)

)

[1] => Array
(
[id] => 4
[name] => Windows 2000
[UsersSystem] => Array
(
[id] => 134
[user_id] => 3
[system_id] => 4
)

)

)

)




Thanks Dave


--~--~---------~--~----~------------~-------~--~----~
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: