Hi Guys,

I have found out where the problem is. The pagination function makes 2
calls.

1. First one for Page Count
2. Second one for Actual Records.

My Page Count query is working fine. But 2nd Query is not working
fine. This is because after the first call model relationships are
reset. As mentioned in the manual, passing the second argument as
false to the following function will work:

$this->Sales->contain(array, false);

But I am not sure how to pass this argument in Pagination. Can anyone
point me in the right direction.

Thanks in Advance.

On Nov 11, 1:58 pm, hunny <[email protected]> wrote:
> Hi Guys,
>
> I have made some breakthrough using Containable in this.
>
> $this->paginate['Sales'] = array('contain' => 'Withdrawn',
> 'conditions' => array('Sales.property_id = Withdrawn.property_id') );
>
> It works fine upto here but in the following statement again it
> doesn't recognizes Withdrawn.property_id
>
> $this->paginate('Sales', array('Sales.property_id =
> Withdrawn.property_id'));
>
> On Nov 10, 3:18 pm, hunny <[email protected]> wrote:
>
> > I have a Table named as sales. I have to join it with itself and
> > achieve the following query.
>
> >          $query = "SELECT `Sales`.`id` FROM `sales` AS `Sales` LEFT
> > JOIN `sales` AS `Withdrawn`
> >          ON (`Sales`.`property_id` = `Withdrawn`.`property_id`)
> >          WHERE `Sales`.`date` = '2009-10-27' AND `Withdrawn`.`id` IS
> > NULL" ;
>
> > In order to achive this I wrote the following code in the controller:
>
> >         $this->Sales->bindModel(array(
> >             'hasOne' => array(
> >                 'Withdrawn' => array(
> >                     'className' => 'Sale',
> >                     'foreignKey' => false,
> >                     'type' => 'LEFT',
> >                     'conditions' => array('Sales.property_id =
> > Withdrawn.property_id')
> >              ))));
>
> > $this->Sales->find('all', array('fields' => 'Sales.id', 'conditions'
> > => array(array('Sales.property_id = Withdrawn.property_id')
>
> > This works absolutely fine. But I need to make use of the Paginator.
> > But when I give the following statement after Binding the Sales Table
> > with its alias Withdrawn Table:
> > $this->paginate('Sales', array('Sales.property_id =
> > Withdrawn.property_id'));
>
> > I get the error that Withdrawn.property_id is not recognized. Any
> > ideas on how to achive this?
>
> > Thanks in Advance.
>
>

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.


Reply via email to