views:

27

answers:

1

This is driving me crazy, I am trying to do something like:

$this->data = $this->Prox->read('proxy',$currentgetdata); 
                    $this->data['Prox']['checked'] = 2;
                    $this->Prox->save();

where I have a model association of:

class Prox extends AppModel {
    var $name = 'Prox';
    var $primaryKey = 'id';
    ######## Define Model Associations #########
    var $belongsTo = array('Proxylink' => array('className' => 'Proxylink'));
}

But I get an error of:

SELECT `Prox`.`proxy` FROM `proxes` AS `Prox` LEFT JOIN `proxylinks` AS `Proxylink` ON (`Prox`.`proxylink_id` = `Proxylink`.`id`) WHERE `Prox`.`id` = '58.22.101.239:808' LIMIT 1

1054: Unknown column 'Prox.proxylink_id' in 'on clause'

I don't get why its putting this into the query "LEFT JOIN proxylinks AS Proxylink ON (Prox.proxylink_id = Proxylink.id)" and I have been unable to find any documentation on why its doing this, its as if it HAS to try to include a non-existant hybrid of a field from my associated model and my current model on each query, which I find extremely bizarre.. any advice is appreciated on what I can do to get my save / update queries to work.

+1  A: 

If you have bolongsTo association your 'prox' table must have 'proxylink_id' field.

If you don't want associative models to be joined you must set 'recursive' option to -1.

bancer
Thanks, that seems to be the solution (set recursive to -1), however the cookbook doesn't give any example for how to implement this, I'm assuming that I just put it into an array somehow, if anyone has an example I would very much appreciate it.. thanks
Rick
`$this->Prox->recursive = -1;` in your controller before query. Another way to set `recursive` shown here - http://book.cakephp.org/view/73/Retrieving-Your-Data. But I would like to direct your attention on the fact that you've got an error on missing foreign key column. That's, probably, because you set the wrong model association (belongsTo).
bancer
thanks for the help, I think I've got it all settled now
Rick