Sunday, September 28, 2008

Re: Filtering on sub table

I think I was not clear and I apologize or i'm not understanding and i apologize too :)

In my view, i've some input on top of my list to filter datas helped with Paginator helper and Filter component.

When i want to filter or sort on a field on 2nd model, i've no problems. But when i want to filter or sort on a field on 3rd or more model, i don't know how do that, and all my tests were been without success.

Ex. :
$array['Program']['ProgramBroadcaster']['id']; //No problem with it
$array['Program']['ProgramBroadcaster']['Broadcaster']['name']; //Not working

Thanks.

Yudao.

On Mon, Sep 29, 2008 at 7:43 AM, glenda guo <gettyying@gmail.com> wrote:
In this case, you can add filter in models when you  create relation with models.

If you don't know how to use the query result in view, you can use print_r function to print the results, then you can know how to use it. 
Also , you can reference this page 
http://book.cakephp.org/view/78/Associations-Linking-Models-Together






On Sun, Sep 28, 2008 at 4:30 PM, Mickael Gentil <mickael.gentil@gmail.com> wrote:
Ok, but the conditions are for the select and not for filtering datas wich is the result from this select, no ?

And on my view what name for my select i can use ?

Because $this->ProgramBroadcaster->Program->ProgramFile->ProgramState is a very deeper relationship.

Thanks.

Yudao.


On Sun, Sep 28, 2008 at 4:19 AM, glenda guo <gettyying@gmail.com> wrote:
$this->set('programStateList', $this->ProgramBroadcaster->
Program->ProgramFile->ProgramState->find('list'));

You can add condition  in it.




On Sat, Sep 27, 2008 at 10:43 PM, Mickael Gentil <mickael.gentil@gmail.com> wrote:
Hi all,

I need some help with a problem.

This is my controller :

<?php
class ProgramBroadcastersController extends AppController {

    var $name = 'ProgramBroadcasters';
    var $components = array('Filter');
    
    var $paginate = array( 
               'limit'=>20,
               'page'=>1,
               'order'=>'ProgramBroadcaster.created DESC',
               'fields'=>array('id','broadcaster_id','program_id','play_date','delivery_date','case_number','video_tape_number'),
               'contain'=>array(
                   'Broadcaster'=>array('fields'=>array('id','name')),
                   'Program'=>array(
                           'ProgramFile'=>array(
                           'fields'=>array('id','program_id','program_state_id'),
                           'ProgramState',
                           'User'=>array('fields'=>array('lastname','firstname'))
                        )
                    )
               )
    );

    public function index()
    {     
        $this->set('broadcasterList', $this->ProgramBroadcaster->Broadcaster->find('list'));
        $this->set('programStateList', $this->ProgramBroadcaster->Program->ProgramFile->ProgramState->find('list'));
       
        $filter = $this->Filter->process($this);
        $this->set('url',$this->Filter->url);
        $this->set('programs', $this->paginate(null, $filter));
       
    }
}

I need to filter datas on ProgramState.id, and i don't know how.

Thanks a lot.

Yudao.













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