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