RE: Array Help

2009-12-25 Thread Dave
Thanks,

I ended up trying a few things and ended up with:

if (empty($value['year_id'])) 
{
unset($this->data['ProfilesSkill'][$key]);
} 

Which does what I need.

Now step away from the computer and enjoy Christmas with your friends an
family!

Have a good holiday everyone.

Dave

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of kangur91
Sent: December-25-09 6:39 PM
To: CakePHP
Subject: Re: Array Help

If you want to remove key from array, it's simple unset(example
below):

foreach($array as $key => $value) {
if($value == "" || $value == " " || is_null($value)) { unset($array[$key]);

You can add if($value != null)

use array_reserve function.

I wish, I help you.

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.

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 
cake-php+at http://groups.google.com/group/cake-php?hl=en
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.722 / Virus Database: 270.14.114/2575 - Release Date: 12/25/09
06:03:00

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Array Help

2009-12-25 Thread kangur91
If you want to remove key from array, it's simple unset(example
below):

foreach($array as $key => $value) {
if($value == "" || $value == " " || is_null($value)) {
unset($array[$key]);

You can add if($value != null)

use array_reserve function.

I wish, I help you.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


RE: Array help

2009-08-11 Thread Dave Maharaj :: WidePixels.com
Thanks Joshua,
 
That works just as needed.
 
Dave

  _  

From: joshua [mailto:josh...@gmail.com] 
Sent: August-11-09 1:14 AM
To: cake-php@googlegroups.com
Subject: Re: Array help


I think you can define a model level filter, it will help you to solve this
problem thoroughly. Just an idea of mine. Maybe you can put the filter
engine in AppModel. 
[Client] > {Filter engine} > [Server]
[Client] <--- {Filter engine} < [Server]


For a temporary solution, I think the loop is enough:
Assume the return result something like this:

[0] => Array
   (
   [Bookmark] => Array
   (
   [id] => 38b7276f708
   [user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b
   [post_id] => 11e7ee
   [created] => 2009-08-09 21:59:01
   )

   [Post] => Array
   (
   [title] => Test Title
   [rank] => 2
   [created] =>
   [description] => Test dscription
   [id] => 52louj

   )

   )
[1] => Array
   (
   [Bookmark] => Array
   (
   [id] => 38b7276f708
   [user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b
   [post_id] => 11e7ee
   [created] => 2009-08-09 21:59:01
   )

   [Post] => Array
   (
   [title] =>
   [rank] =>
   [created] =>
   [description] =>
   [id] =>

   )

   )


[CODE]
foreach ($bookmarks as $key => $value) {
 if (empty($value['Post']['id'])) {
  unset($bookmarks[$key]['Post']);
 }
}
[/CODE]

On Tue, Aug 11, 2009 at 11:19 AM, Dave Maharaj :: WidePixels.com
 wrote:


The thing is the Post info is there in the database
 
Scenario:
The Post article has access level of 1
User that has an access level of 1 can see the Post and bookmark it. No
problem
 
Later the owner of the Post changes the access level to 3the user with
level 1 access can no loger see that Post because his access level is too
low, but his Bookmark for that Post still exists. But because the contain
will pull all bookmarks that belongto the user andgetthe Posts where $access
= 'Post.access' that info is no longer goingto get pulled, thats why it
appears blank.
 
So I need to completely remove that bookmark from the array.
 
Trying something like:
 
foreach ($bookmark as $key => $value) {
 if (empty($value)) {
  unset($q[$key]);
 
but cant get it to work...still messing around with it

  _  

From: joshua [mailto:josh...@gmail.com] 
Sent: August-11-09 12:41 AM
To: cake-php@googlegroups.com
Subject: Re: Array help


1. Use a callback function afterFind to loop the return array, remove the
empty item. 
2. How about give a condition when model->find.
[CODE]
'conditions' => array(("not" => array ( "Post.id" => null )), //array of
conditions
[/CODE]

On Tue, Aug 11, 2009 at 10:25 AM, Dave Maharaj :: WidePixels.com
 wrote:



I have a contain query which produces these results.

Basically the user bookmarked a page when they had access. The Owner of the
post has changed the level of who can view the Post so in this case this
user no longer can view the post hence the missing post data. It was not
grabbed because the conditions of the Post did not match the users access
level.

But the bookmark still exists. Now in the query it pulls all bookmarks for
the user and the post related to the bookmark. How can I remove [1] from the
array all together or all from the array if [Post] has no data? I can not
delete the bookmark when Posts change the access level because they may
change it back to a lower setting and allow those who did have it bookmarked
to once again have access. I just need to remove the array entry(s) where
the  Post array is empty.

[0] => Array
   (
   [Bookmark] => Array
   (
   [id] => 38b7276f708
   [user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b
   [post_id] => 11e7ee
   [created] => 2009-08-09 21:59:01
   )

   [Post] => Array
   (
   [title] => Test Title
   [rank] => 2
   [created] =>
   [description] => Test dscription
   [id] => 52louj

   )

   )
[1] => Array
   (
   [Bookmark] => Array
   (
   [id] => 38b7276f708
   [user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b
   [post_id] => 11e7ee
   [created] => 2009-08-09 21:59:01
   )

   

Re: Array help

2009-08-10 Thread Martin Westin


If looping the results start becoming too slow for you, you can force
Cake to do a join which will make the whole result disappear if the
Post is empty.

Nate wrote about it and inspired me to build my own variation.
http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-in-model-find

My take on it was to make the syntax as close to Containable as I
could. I pasted some code into the bin for anyone who wants a peek.
Feel free to make use of it... if it works for you. I have only tested
it in a very limited way and do not use it that much.
http://bin.cakephp.org/view/992365224





On Aug 11, 5:44 am, joshua  wrote:
> I think you can define a model level filter, it will help you to solve this
> problem thoroughly. Just an idea of mine. Maybe you can put the filter
> engine in AppModel.[Client] > {Filter engine} > [Server]
> [Client] <--- {Filter engine} < [Server]
>
> For a temporary solution, I think the loop is enough:
> Assume the return result something like this:
>
> [0] => Array
>        (
>            [Bookmark] => Array
>                (
>                    [id] => 38b7276f708
>                    [user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b
>                    [post_id] => 11e7ee
>                    [created] => 2009-08-09 21:59:01
>                )
>
>            [Post] => Array
>                (
>                    [title] => Test Title
>                    [rank] => 2
>                    [created] =>
>                    [description] => Test dscription
>                    [id] => 52louj
>
>                )
>
>        )
> [1] => Array
>        (
>            [Bookmark] => Array
>                (
>                    [id] => 38b7276f708
>                    [user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b
>                    [post_id] => 11e7ee
>                    [created] => 2009-08-09 21:59:01
>                )
>
>            [Post] => Array
>                (
>                    [title] =>
>                    [rank] =>
>                    [created] =>
>                    [description] =>
>                    [id] =>
>
>                )
>
>        )
>
> [CODE]
> foreach ($bookmarks as $key => $value) {
>      if (empty($value['Post']['id'])) {
>       unset($bookmarks[$key]['Post']);
>      }}
>
> [/CODE]
> On Tue, Aug 11, 2009 at 11:19 AM, Dave Maharaj :: WidePixels.com <
>
>
>
>
>
> d...@widepixels.com> wrote:
> >  The thing is the Post info is there in the database
>
> > Scenario:
> > The Post article has access level of 1
> > User that has an access level of 1 can see the Post and bookmark it. No
> > problem
>
> > Later the owner of the Post changes the access level to 3the user with
> > level 1 access can no loger see that Post because his access level is too
> > low, but his Bookmark for that Post still exists. But because the contain
> > will pull all bookmarks that belongto the user andgetthe Posts where $access
> > = 'Post.access' that info is no longer goingto get pulled, thats why it
> > appears blank.
>
> > So I need to completely remove that bookmark from the array.
>
> > Trying something like:
>
> > foreach ($bookmark as $key => $value) {
> >      if (empty($value)) {
> >       unset($q[$key]);
>
> > but cant get it to work...still messing around with it
>
> >  --
> > *From:* joshua [mailto:josh...@gmail.com]
> > *Sent:* August-11-09 12:41 AM
> > *To:* cake-php@googlegroups.com
> > *Subject:* Re: Array help
>
> > 1. Use a callback function afterFind to loop the return array, remove the
> > empty item. 2. How about give a condition when model->find.
> > [CODE]
> > 'conditions' => array(("*not*" => array ( "Post.id" => *null* )), //array
> > of conditions
> > [/CODE]
> > On Tue, Aug 11, 2009 at 10:25 AM, Dave Maharaj :: WidePixels.com <
> > d...@widepixels.com> wrote:
>
> >> I have a contain query which produces these results.
>
> >> Basically the user bookmarked a page when they had access. The Owner of
> >> the
> >> post has changed the level of who can view the Post so in this case this
> >> user no longer can view the post hence the missing post data. It was not
> >> grabbed because the conditions of the Post did not match the users access
> >> level.
>
> >> But the bookmark still exists. Now in the query it pulls all

Re: Array help

2009-08-10 Thread joshua
I think you can define a model level filter, it will help you to solve this
problem thoroughly. Just an idea of mine. Maybe you can put the filter
engine in AppModel.[Client] > {Filter engine} > [Server]
[Client] <--- {Filter engine} < [Server]

For a temporary solution, I think the loop is enough:
Assume the return result something like this:

[0] => Array
   (
   [Bookmark] => Array
   (
   [id] => 38b7276f708
   [user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b
   [post_id] => 11e7ee
   [created] => 2009-08-09 21:59:01
   )

   [Post] => Array
   (
   [title] => Test Title
   [rank] => 2
   [created] =>
   [description] => Test dscription
   [id] => 52louj

   )

   )
[1] => Array
   (
   [Bookmark] => Array
   (
   [id] => 38b7276f708
   [user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b
   [post_id] => 11e7ee
   [created] => 2009-08-09 21:59:01
   )

   [Post] => Array
   (
   [title] =>
   [rank] =>
   [created] =>
   [description] =>
   [id] =>

   )

   )


[CODE]
foreach ($bookmarks as $key => $value) {
 if (empty($value['Post']['id'])) {
  unset($bookmarks[$key]['Post']);
 }
}
[/CODE]
On Tue, Aug 11, 2009 at 11:19 AM, Dave Maharaj :: WidePixels.com <
d...@widepixels.com> wrote:

>  The thing is the Post info is there in the database
>
> Scenario:
> The Post article has access level of 1
> User that has an access level of 1 can see the Post and bookmark it. No
> problem
>
> Later the owner of the Post changes the access level to 3the user with
> level 1 access can no loger see that Post because his access level is too
> low, but his Bookmark for that Post still exists. But because the contain
> will pull all bookmarks that belongto the user andgetthe Posts where $access
> = 'Post.access' that info is no longer goingto get pulled, thats why it
> appears blank.
>
> So I need to completely remove that bookmark from the array.
>
> Trying something like:
>
> foreach ($bookmark as $key => $value) {
>  if (empty($value)) {
>   unset($q[$key]);
>
> but cant get it to work...still messing around with it
>
>  --
> *From:* joshua [mailto:josh...@gmail.com]
> *Sent:* August-11-09 12:41 AM
> *To:* cake-php@googlegroups.com
> *Subject:* Re: Array help
>
> 1. Use a callback function afterFind to loop the return array, remove the
> empty item. 2. How about give a condition when model->find.
> [CODE]
> 'conditions' => array(("*not*" => array ( "Post.id" => *null* )), //array
> of conditions
> [/CODE]
> On Tue, Aug 11, 2009 at 10:25 AM, Dave Maharaj :: WidePixels.com <
> d...@widepixels.com> wrote:
>
>>
>> I have a contain query which produces these results.
>>
>> Basically the user bookmarked a page when they had access. The Owner of
>> the
>> post has changed the level of who can view the Post so in this case this
>> user no longer can view the post hence the missing post data. It was not
>> grabbed because the conditions of the Post did not match the users access
>> level.
>>
>> But the bookmark still exists. Now in the query it pulls all bookmarks for
>> the user and the post related to the bookmark. How can I remove [1] from
>> the
>> array all together or all from the array if [Post] has no data? I can not
>> delete the bookmark when Posts change the access level because they may
>> change it back to a lower setting and allow those who did have it
>> bookmarked
>> to once again have access. I just need to remove the array entry(s) where
>> the  Post array is empty.
>>
>> [0] => Array
>>(
>>[Bookmark] => Array
>>(
>>[id] => 38b7276f708
>>[user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b
>>[post_id] => 11e7ee
>>[created] => 2009-08-09 21:59:01
>>)
>>
>>[Post] => Array
>>(
>>[title] => Test Title
>>[rank] => 2
>>[created] =>
>>[description] => Te

RE: Array help

2009-08-10 Thread Dave Maharaj :: WidePixels.com
The thing is the Post info is there in the database
 
Scenario:
The Post article has access level of 1
User that has an access level of 1 can see the Post and bookmark it. No
problem
 
Later the owner of the Post changes the access level to 3the user with
level 1 access can no loger see that Post because his access level is too
low, but his Bookmark for that Post still exists. But because the contain
will pull all bookmarks that belongto the user andgetthe Posts where $access
= 'Post.access' that info is no longer goingto get pulled, thats why it
appears blank.
 
So I need to completely remove that bookmark from the array.
 
Trying something like:
 
foreach ($bookmark as $key => $value) {
 if (empty($value)) {
  unset($q[$key]);
 
but cant get it to work...still messing around with it

  _  

From: joshua [mailto:josh...@gmail.com] 
Sent: August-11-09 12:41 AM
To: cake-php@googlegroups.com
Subject: Re: Array help


1. Use a callback function afterFind to loop the return array, remove the
empty item. 
2. How about give a condition when model->find.
[CODE]
'conditions' => array(("not" => array ( "Post.id" => null )), //array of
conditions
[/CODE]

On Tue, Aug 11, 2009 at 10:25 AM, Dave Maharaj :: WidePixels.com
 wrote:



I have a contain query which produces these results.

Basically the user bookmarked a page when they had access. The Owner of the
post has changed the level of who can view the Post so in this case this
user no longer can view the post hence the missing post data. It was not
grabbed because the conditions of the Post did not match the users access
level.

But the bookmark still exists. Now in the query it pulls all bookmarks for
the user and the post related to the bookmark. How can I remove [1] from the
array all together or all from the array if [Post] has no data? I can not
delete the bookmark when Posts change the access level because they may
change it back to a lower setting and allow those who did have it bookmarked
to once again have access. I just need to remove the array entry(s) where
the  Post array is empty.

[0] => Array
   (
   [Bookmark] => Array
   (
   [id] => 38b7276f708
   [user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b
   [post_id] => 11e7ee
   [created] => 2009-08-09 21:59:01
   )

   [Post] => Array
   (
   [title] => Test Title
   [rank] => 2
   [created] =>
   [description] => Test dscription
   [id] => 52louj

   )

   )
[1] => Array
   (
   [Bookmark] => Array
   (
   [id] => 38b7276f708
   [user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b
   [post_id] => 11e7ee
   [created] => 2009-08-09 21:59:01
   )

   [Post] => Array
   (
   [title] =>
   [rank] =>
   [created] =>
   [description] =>
   [id] =>

   )

   )

Thanks,

Dave








-- 
Thanks
Joshua

5span.com <https://www.5span.com> 




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



Re: Array help

2009-08-10 Thread joshua
1. Use a callback function afterFind to loop the return array, remove the
empty item.2. How about give a condition when model->find.
[CODE]
'conditions' => array(("*not*" => array ( "Post.id" => *null* )), //array of
conditions
[/CODE]
On Tue, Aug 11, 2009 at 10:25 AM, Dave Maharaj :: WidePixels.com <
d...@widepixels.com> wrote:

>
> I have a contain query which produces these results.
>
> Basically the user bookmarked a page when they had access. The Owner of the
> post has changed the level of who can view the Post so in this case this
> user no longer can view the post hence the missing post data. It was not
> grabbed because the conditions of the Post did not match the users access
> level.
>
> But the bookmark still exists. Now in the query it pulls all bookmarks for
> the user and the post related to the bookmark. How can I remove [1] from
> the
> array all together or all from the array if [Post] has no data? I can not
> delete the bookmark when Posts change the access level because they may
> change it back to a lower setting and allow those who did have it
> bookmarked
> to once again have access. I just need to remove the array entry(s) where
> the  Post array is empty.
>
> [0] => Array
>(
>[Bookmark] => Array
>(
>[id] => 38b7276f708
>[user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b
>[post_id] => 11e7ee
>[created] => 2009-08-09 21:59:01
>)
>
>[Post] => Array
>(
>[title] => Test Title
>[rank] => 2
>[created] =>
>[description] => Test dscription
>[id] => 52louj
>
>)
>
>)
> [1] => Array
>(
>[Bookmark] => Array
>(
>[id] => 38b7276f708
>[user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b
>[post_id] => 11e7ee
>[created] => 2009-08-09 21:59:01
>)
>
>[Post] => Array
>(
>[title] =>
>[rank] =>
>[created] =>
>[description] =>
>[id] =>
>
>)
>
>)
>
> Thanks,
>
> Dave
>
>
> >
>


-- 
Thanks
Joshua
5span.com 

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



RE: Array Help

2009-07-22 Thread Dave Maharaj :: WidePixels.com

Figured it out... Stupid mistake on my part.

Thanks guys.

Dave 

-Original Message-
From: Jeff Griffiths [mailto:anisotro...@gmail.com] 
Sent: July-22-09 2:32 PM
To: cake-php@googlegroups.com
Subject: Re: Array Help

I'm not sure I understand. If you have this data structure in your
controller, can you not just set:

$this->set('array_of_entries_or_something', $data['ShowCase'][0]['Entry']);

... and then in the view expect to be able to do this:

foreach ($array_of_entries_or_something as $entry) {
// blah blah
}

Jeff


On Wed, Jul 22, 2009 at 9:49 AM, Dave Maharaj ::
WidePixels.com wrote:
>  SELECT * FROM entries WHERE showcase_id = '6bd19a7775f'; Returns 
> nothing because that Showcase has no Entries
>
> SELECT * FROM entries WHERE showcase_id = '5edd082b249'; Returns the 5 
> test entries I have added for that Showcase
>
> The correct data is being pulled I just cant get the 
> ['Entry']['image'] for each of the ['Showcases'] to the view.
>
> Dave
>
> -Original Message-
> From: brian [mailto:bally.z...@gmail.com]
> Sent: July-22-09 2:07 PM
> To: cake-php@googlegroups.com
> Subject: Re: Array Help
>
> Run this query on the DB:
>
> SELECT * FROM entries WHERE showcase_id = '6bd19a7775f';
>
> See anything?
>
> On Wed, Jul 22, 2009 at 12:22 PM, Dave Maharaj ::
> WidePixels.com wrote:
>>
>> I have this array and trying to do a for each Showcase Entry to show 
>> up with the Showcase.
>>
>> I just cant seem to get the Entry array for each Showcase to appear.
>>
>> Each Showcase apers but no Entry associated with it.
>>
>> [Showcase] => Array
>>        (
>>            [0] => Array
>>                (
>>                    [id] => 5edd082b249
>>                    [created] => 2009-07-15 21:40:11
>>                    [modified] => 2009-07-15 21:40:11
>>                    [Entry] => Array
>>                        (
>>                            [0] => Array
>>                                (
>>                                    [id] => 262c13a743e
>>                                    [showcase_id] => 5edd082b249
>>                                    [order] => 0
>>                                    [image] => 262c13a743e.jpg
>>                                )
>>
>>                            [1] => Array
>>                                (
>>                                    [id] => 2b9fd9e1264
>>                                    [showcase_id] => 5edd082b249
>>                                    [order] => 0
>>                                    [image] => 2b9fd9e1264.jpg
>>                                )
>>
>>                            [2] => Array
>>                                (
>>                                    [id] => 7bc121658d5
>>                                    [showcase_id] => 5edd082b249
>>                                    [order] => 0
>>                                    [image] => 7bc121658d5.jpg
>>                                )
>>
>>                            [3] => Array
>>                                (
>>                                    [id] => cf633a6da88
>>                                    [showcase_id] => 5edd082b249
>>                                    [order] => 0
>>                                    [image] => cf633a6da88.jpg
>>                                )
>>
>>                            [4] => Array
>>                                (
>>                                    [id] => db775cd8456
>>                                    [showcase_id] => 5edd082b249
>>                                    [order] => 0
>>                                    [image] => 
>> petemaharaj_db775cd8456.jpg
>>                                )
>>
>>                        )
>>
>>                )
>>
>>            [1] => Array
>>                (
>>                    [id] => 6bd19a7775f
>>                    [created] => 2009-07-15 21:39:16
>>                    [modified] => 2009-07-15 21:39:16
>>                    [Entry] => Array
>>                        (
>>                        )
>>
>>                )
>>
>>
>> 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Array Help

2009-07-22 Thread Dave Maharaj :: WidePixels.com

When I try this:

$entry = Set::extract('Showcase.{n}.Entry.{n}.image', $portfolio);
debug($entry); 

I get:

Array
(
[0] => Array
(
[0] => 262c13a743e.jpg
[1] => 2b9fd9e1264.jpg
[2] => 7bc121658d5.jpg
[3] => cf633a6da88.jpg
[4] => db775cd8456.jpg
)

[1] => Array
(
)

[2] => Array
(
)

[3] => Array
(
)

[4] => Array
(
)

)

I just need help with the view so Showcase shows up and the Entry images
show up with that Showcase.

Foreach ['Showcase]'.{n}.['Entry'].{n}.['image'] <= I just don’t know how to
use the numbers from the array where {n} is





   

-Original Message-
From: Dave Maharaj :: WidePixels.com [mailto:d...@widepixels.com] 
Sent: July-22-09 2:20 PM
To: cake-php@googlegroups.com
Subject: RE: Array Help

 SELECT * FROM entries WHERE showcase_id = '6bd19a7775f'; Returns nothing
because that Showcase has no Entries

SELECT * FROM entries WHERE showcase_id = '5edd082b249'; Returns the 5 test
entries I have added for that Showcase 

The correct data is being pulled I just cant get the ['Entry']['image'] for
each of the ['Showcases'] to the view.

Dave

-Original Message-----
From: brian [mailto:bally.z...@gmail.com]
Sent: July-22-09 2:07 PM
To: cake-php@googlegroups.com
Subject: Re: Array Help

Run this query on the DB:

SELECT * FROM entries WHERE showcase_id = '6bd19a7775f';

See anything?

On Wed, Jul 22, 2009 at 12:22 PM, Dave Maharaj ::
WidePixels.com wrote:
>
> I have this array and trying to do a for each Showcase Entry to show 
> up with the Showcase.
>
> I just cant seem to get the Entry array for each Showcase to appear.
>
> Each Showcase apers but no Entry associated with it.
>
> [Showcase] => Array
>        (
>            [0] => Array
>                (
>                    [id] => 5edd082b249
>                    [created] => 2009-07-15 21:40:11
>                    [modified] => 2009-07-15 21:40:11
>                    [Entry] => Array
>                        (
>                            [0] => Array
>                                (
>                                    [id] => 262c13a743e
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => 262c13a743e.jpg
>                                )
>
>                            [1] => Array
>                                (
>                                    [id] => 2b9fd9e1264
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => 2b9fd9e1264.jpg
>                                )
>
>                            [2] => Array
>                                (
>                                    [id] => 7bc121658d5
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => 7bc121658d5.jpg
>                                )
>
>                            [3] => Array
>                                (
>                                    [id] => cf633a6da88
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => cf633a6da88.jpg
>                                )
>
>                            [4] => Array
>                                (
>                                    [id] => db775cd8456
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => 
> petemaharaj_db775cd8456.jpg
>                                )
>
>                        )
>
>                )
>
>            [1] => Array
>                (
>                    [id] => 6bd19a7775f
>                    [created] => 2009-07-15 21:39:16
>                    [modified] => 2009-07-15 21:39:16
>                    [Entry] => Array
>                        (
>                        )
>
>                )
>
>
> 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Array Help

2009-07-22 Thread Jeff Griffiths
I'm not sure I understand. If you have this data structure in your
controller, can you not just set:

$this->set('array_of_entries_or_something', $data['ShowCase'][0]['Entry']);

... and then in the view expect to be able to do this:

foreach ($array_of_entries_or_something as $entry) {
// blah blah
}

Jeff


On Wed, Jul 22, 2009 at 9:49 AM, Dave Maharaj ::
WidePixels.com wrote:
>  SELECT * FROM entries WHERE showcase_id = '6bd19a7775f';
> Returns nothing because that Showcase has no Entries
>
> SELECT * FROM entries WHERE showcase_id = '5edd082b249';
> Returns the 5 test entries I have added for that Showcase
>
> The correct data is being pulled I just cant get the ['Entry']['image'] for
> each of the ['Showcases'] to the view.
>
> Dave
>
> -Original Message-
> From: brian [mailto:bally.z...@gmail.com]
> Sent: July-22-09 2:07 PM
> To: cake-php@googlegroups.com
> Subject: Re: Array Help
>
> Run this query on the DB:
>
> SELECT * FROM entries WHERE showcase_id = '6bd19a7775f';
>
> See anything?
>
> On Wed, Jul 22, 2009 at 12:22 PM, Dave Maharaj ::
> WidePixels.com wrote:
>>
>> I have this array and trying to do a for each Showcase Entry to show
>> up with the Showcase.
>>
>> I just cant seem to get the Entry array for each Showcase to appear.
>>
>> Each Showcase apers but no Entry associated with it.
>>
>> [Showcase] => Array
>>        (
>>            [0] => Array
>>                (
>>                    [id] => 5edd082b249
>>                    [created] => 2009-07-15 21:40:11
>>                    [modified] => 2009-07-15 21:40:11
>>                    [Entry] => Array
>>                        (
>>                            [0] => Array
>>                                (
>>                                    [id] => 262c13a743e
>>                                    [showcase_id] => 5edd082b249
>>                                    [order] => 0
>>                                    [image] => 262c13a743e.jpg
>>                                )
>>
>>                            [1] => Array
>>                                (
>>                                    [id] => 2b9fd9e1264
>>                                    [showcase_id] => 5edd082b249
>>                                    [order] => 0
>>                                    [image] => 2b9fd9e1264.jpg
>>                                )
>>
>>                            [2] => Array
>>                                (
>>                                    [id] => 7bc121658d5
>>                                    [showcase_id] => 5edd082b249
>>                                    [order] => 0
>>                                    [image] => 7bc121658d5.jpg
>>                                )
>>
>>                            [3] => Array
>>                                (
>>                                    [id] => cf633a6da88
>>                                    [showcase_id] => 5edd082b249
>>                                    [order] => 0
>>                                    [image] => cf633a6da88.jpg
>>                                )
>>
>>                            [4] => Array
>>                                (
>>                                    [id] => db775cd8456
>>                                    [showcase_id] => 5edd082b249
>>                                    [order] => 0
>>                                    [image] =>
>> petemaharaj_db775cd8456.jpg
>>                                )
>>
>>                        )
>>
>>                )
>>
>>            [1] => Array
>>                (
>>                    [id] => 6bd19a7775f
>>                    [created] => 2009-07-15 21:39:16
>>                    [modified] => 2009-07-15 21:39:16
>>                    [Entry] => Array
>>                        (
>>                        )
>>
>>                )
>>
>>
>> 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Array Help

2009-07-22 Thread Dave Maharaj :: WidePixels.com
 SELECT * FROM entries WHERE showcase_id = '6bd19a7775f';
Returns nothing because that Showcase has no Entries

SELECT * FROM entries WHERE showcase_id = '5edd082b249';
Returns the 5 test entries I have added for that Showcase 

The correct data is being pulled I just cant get the ['Entry']['image'] for
each of the ['Showcases'] to the view.

Dave

-Original Message-
From: brian [mailto:bally.z...@gmail.com] 
Sent: July-22-09 2:07 PM
To: cake-php@googlegroups.com
Subject: Re: Array Help

Run this query on the DB:

SELECT * FROM entries WHERE showcase_id = '6bd19a7775f';

See anything?

On Wed, Jul 22, 2009 at 12:22 PM, Dave Maharaj ::
WidePixels.com wrote:
>
> I have this array and trying to do a for each Showcase Entry to show 
> up with the Showcase.
>
> I just cant seem to get the Entry array for each Showcase to appear.
>
> Each Showcase apers but no Entry associated with it.
>
> [Showcase] => Array
>        (
>            [0] => Array
>                (
>                    [id] => 5edd082b249
>                    [created] => 2009-07-15 21:40:11
>                    [modified] => 2009-07-15 21:40:11
>                    [Entry] => Array
>                        (
>                            [0] => Array
>                                (
>                                    [id] => 262c13a743e
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => 262c13a743e.jpg
>                                )
>
>                            [1] => Array
>                                (
>                                    [id] => 2b9fd9e1264
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => 2b9fd9e1264.jpg
>                                )
>
>                            [2] => Array
>                                (
>                                    [id] => 7bc121658d5
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => 7bc121658d5.jpg
>                                )
>
>                            [3] => Array
>                                (
>                                    [id] => cf633a6da88
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => cf633a6da88.jpg
>                                )
>
>                            [4] => Array
>                                (
>                                    [id] => db775cd8456
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => 
> petemaharaj_db775cd8456.jpg
>                                )
>
>                        )
>
>                )
>
>            [1] => Array
>                (
>                    [id] => 6bd19a7775f
>                    [created] => 2009-07-15 21:39:16
>                    [modified] => 2009-07-15 21:39:16
>                    [Entry] => Array
>                        (
>                        )
>
>                )
>
>
> 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Array Help

2009-07-22 Thread brian
Run this query on the DB:

SELECT * FROM entries WHERE showcase_id = '6bd19a7775f';

See anything?

On Wed, Jul 22, 2009 at 12:22 PM, Dave Maharaj ::
WidePixels.com wrote:
>
> I have this array and trying to do a for each Showcase Entry to show up with
> the Showcase.
>
> I just cant seem to get the Entry array for each Showcase to appear.
>
> Each Showcase apers but no Entry associated with it.
>
> [Showcase] => Array
>        (
>            [0] => Array
>                (
>                    [id] => 5edd082b249
>                    [created] => 2009-07-15 21:40:11
>                    [modified] => 2009-07-15 21:40:11
>                    [Entry] => Array
>                        (
>                            [0] => Array
>                                (
>                                    [id] => 262c13a743e
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => 262c13a743e.jpg
>                                )
>
>                            [1] => Array
>                                (
>                                    [id] => 2b9fd9e1264
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => 2b9fd9e1264.jpg
>                                )
>
>                            [2] => Array
>                                (
>                                    [id] => 7bc121658d5
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => 7bc121658d5.jpg
>                                )
>
>                            [3] => Array
>                                (
>                                    [id] => cf633a6da88
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => cf633a6da88.jpg
>                                )
>
>                            [4] => Array
>                                (
>                                    [id] => db775cd8456
>                                    [showcase_id] => 5edd082b249
>                                    [order] => 0
>                                    [image] => petemaharaj_db775cd8456.jpg
>                                )
>
>                        )
>
>                )
>
>            [1] => Array
>                (
>                    [id] => 6bd19a7775f
>                    [created] => 2009-07-15 21:39:16
>                    [modified] => 2009-07-15 21:39:16
>                    [Entry] => Array
>                        (
>                        )
>
>                )
>
>
> 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Array Help

2009-06-22 Thread Dave Maharaj :: WidePixels.com

Thanks... Works like a charm!

Had to change it to:
$combined = array();
foreach ($id as $key=>$value) {
$combined[$key] = array('id'=>$value ,
'percent'=>$percent[$key]); 

}
  debug($combined);

Which makes;

Array
(
[0] => Array
(
[id] => 3
[percent] => 100
)

[1] => Array
(
[id] => 4
[percent] => 100
)
)
. And so on for each

How would I then use this array for pagination?

$data = $this->paginate('Job', array('Job.id' =>  $combined ));



-Original Message-
From: kdubya [mailto:kenwin...@winanstech.com] 
Sent: June-22-09 10:45 AM
To: CakePHP
Subject: Re: Array Help


Try something like this (assuming the two arrays you mentioned are called
$id and $percent respectively):

$combined = array();
foreach ($id as $key=>$value) {
  $combined[$key] = array('id'=>$value), 'percent'=>$percent[$key]); }


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



Re: Array Help

2009-06-22 Thread kdubya

Try something like this (assuming the two arrays you mentioned are
called $id and $percent respectively):

$combined = array();
foreach ($id as $key=>$value) {
  $combined[$key] = array('id'=>$value), 'percent'=>$percent[$key]);
}
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



RE: Array Help

2009-06-21 Thread Dave Maharaj :: WidePixels.com

I tried extract / merge / combine / tried regular array functions push and I
just cant get this.
Read the eat arrays for breakfast link but I am not extracting from a path,
id's are already extracted thru a search and percent is a function run on
each extracted id. Now I need to create an array to pass to pagination that
has the percent and id 

Tried foreach loops and still nothing.

Can someone point out how to exactly get the pairs for each key to create an
array for each

I have 2 separate arrays, one is just the id's the other is the percentage
Id's:
Array
(
[0] => 3
[1] => 4
[2] => 5
[3] => 6
[4] => 7
}

Percent array:
Array
(
[0] => 28
[1] => 39
[2] => 17
[3] => 28
[4] => 23


So it would end up like:
Array
(
[0] => Array

(
 [id] => 3
 [percent] => 28
 )

[1] => Array

(
 [id] => 4
 [percent] => 39
 )

[2] => Array

(
 [id] => 5
 [percent] => 17
 )

[3] => Array

(
 [id] => 6
 [percent] => 28
 )

[4] => Array

(
 [id] => 7
 [percent] => 23
 )

) 

Thanks,

Dave
-Original Message-
From: mike karthauser [mailto:mi...@brightstorm.co.uk] 
Sent: June-21-09 10:08 AM
To: cake-php@googlegroups.com
Subject: Re: Array Help


hi dave

On 21 Jun 2009, at 13:35, Dave Maharaj :: WidePixels.com wrote:



How can I edit this  array:  
Array
(
   [Test] => Array
   (
   [Post] => Array
   (
   [0] => 3
   [1] => 4
   [2] => 5
   [3] => 6
   [4] => 7
   [5] => 8
   [6] => 9
   )

   [Percent] => Array
   (
   [0] => 28
   [1] => 39
   [2] => 17
   [3] => 28
   [4] => 23
   [5] => 17
   [6] => 17
   )

   )

)

Into something like : take each key from POST and PERCENT, and pair
them up 
Array
(
   [Test] => Array
   (
   [0] => Array
   (
   [Post] => 3
 [Percent] => 28
   )
 )
)



by using set::extract

http://debuggable.com/posts/cake-12s-set-class-eats-arrays-for-breakfast


YMMV

regards
mikek

--
Mike Karthäuser
Managing Director - Brightstorm Ltd
Email: mi...@brightstorm.co.uk
Web: http://www.brightstorm.co.uk <http://www.brightstorm.co.uk/>
Tel: 07939 252144 (mobile)
Fax: 0870 1320560
Address: 1 Brewery Court, North Street, Bristol, BS3 1JS






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



RE: Array Help

2009-06-21 Thread Dave Maharaj :: WidePixels.com

Still no luck. I think I merged the 2 arrays too soon.
 
I get a list of Posts from a search. Then run a function to determine the
percentage match for the results based which spits out a $percentage array
for each of the $posts array

So I have 2 separate arrays to work with, and stuck on combine / merge them
into 1 array matching up the keys
 
so originally i have the lists of Post id's
Array
(
[Posts] => Array
(
[0] => 3
[1] => 4
[2] => 5
[3] => 6
[4] => 7
[5] => 8

  )
)
Then a Percentage for each of the Posts
Array
(
[Percent] => Array
(
[0] => 36
[1] => 85
[2] => 25
[3] => 17
[4] => 85
[5] => 17

  )
)

And end up with 1 array where the keys are matched up for each as every Post
will have a partner Percentage


From: mike karthauser [mailto:mi...@brightstorm.co.uk] 
Sent: June-21-09 10:08 AM
To: cake-php@googlegroups.com
Subject: Re: Array Help



hi dave 

On 21 Jun 2009, at 13:35, Dave Maharaj :: WidePixels.com wrote:



How can I edit this  array:
Array
(
   [Test] => Array
   (
   [Post] => Array
   (
   [0] => 3
   [1] => 4
   [2] => 5
   [3] => 6
   [4] => 7
   [5] => 8
   [6] => 9
   )

   [Percent] => Array
   (
   [0] => 28
   [1] => 39
   [2] => 17
   [3] => 28
   [4] => 23
   [5] => 17
   [6] => 17
   )

   )

)

Into something like : take each key from POST and PERCENT, and pair
them up 
Array
(
   [Test] => Array
   (
   [0] => Array
   (
   [Post] => 3
 [Percent] => 28
   )
 )
)



by using set::extract

http://debuggable.com/posts/cake-12s-set-class-eats-arrays-for-breakfast


YMMV

regards
mikek

-- 
Mike Karthäuser
Managing Director - Brightstorm Ltd 
Email: mi...@brightstorm.co.uk 
Web: http://www.brightstorm.co.uk <http://www.brightstorm.co.uk/>  
Tel: 07939 252144 (mobile) 
Fax: 0870 1320560 
Address: 1 Brewery Court, North Street, Bristol, BS3 1JS






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



Re: Array Help

2009-06-21 Thread mike karthauser

hi dave

On 21 Jun 2009, at 13:35, Dave Maharaj :: WidePixels.com wrote:

>
> How can I edit this  array:
> Array
> (
>[Test] => Array
>(
>[Post] => Array
>(
>[0] => 3
>[1] => 4
>[2] => 5
>[3] => 6
>[4] => 7
>[5] => 8
>[6] => 9
>)
>
>[Percent] => Array
>(
>[0] => 28
>[1] => 39
>[2] => 17
>[3] => 28
>[4] => 23
>[5] => 17
>[6] => 17
>)
>
>)
>
> )
>
> Into something like : take each key from POST and PERCENT, and pair  
> them up
> Array
> (
>[Test] => Array
>(
>[0] => Array
>(
>[Post] => 3
> [Percent] => 28
>)
> )
> )


by using set::extract

http://debuggable.com/posts/cake-12s-set-class-eats-arrays-for-breakfast


YMMV

regards
mikek

-- 
Mike Karthäuser
Managing Director - Brightstorm Ltd
Email: mi...@brightstorm.co.uk
Web: http://www.brightstorm.co.uk
Tel: 07939 252144 (mobile)
Fax: 0870 1320560
Address: 1 Brewery Court, North Street, Bristol, BS3 1JS


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