arrays: same data, same views, but other structure

2006-09-13 Thread [EMAIL PROTECTED]
Hey guys, take for expample these 3 models: news ,replies and user (news hasmany replies, replies belongsto news, user hasmany replies, replies belongsto user) if i do a $this-Reply-findAll(); and pr() the result, i get something like this:

Re: arrays: same data, same views, but other structure

2006-09-13 Thread [EMAIL PROTECTED]
Sounds like you just need to be careful of how you pass data into the ReplyElement you have created. For the first you pass just the $data itself. For the second where you have multiple replies you are going to have to use a loop. foreach ($data['Reply'] as $row) {

Re: arrays: same data, same views, but other structure

2006-09-13 Thread [EMAIL PROTECTED]
okay i like that. it's not super-clean like i hoped it would be, but it certainly does the job really well and simple. I don't really understand how you come up witht he code you wrote, especially the row thing, anyway, you bumped me in the right direction, and now i just use this for the 2nd

Re: arrays: same data, same views, but other structure

2006-09-13 Thread [EMAIL PROTECTED]
One thing I noticed is the use of an $i variable there. Looks like maybe you are doing a for loop?? That is probably making a lot of $news[$i]['Reply']['etc'] variables in your code block. Instead using the foreach ($news as $row) would make them $row['Reply']['etc'] and clean up your code a

Re: arrays: same data, same views, but other structure

2006-09-13 Thread [EMAIL PROTECTED]
oh, right, i used for loops there for a good reason in the past (i needed to know exactly the index of the array), but now i don't need it anymore. gonna change it to foreach ;) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the