been on holiday for a week.
Here's the error I am getting:
$sql = "SELECT `Cat`.`id`, `Cat`.`title`, `Cat`.`location_id`,
`Cat`.`created`, `Cat`.`modified` FROM `cats` AS `Cat` WHERE
`Subcat`.`cat_id` = `Cat`.`id` "
$error = "1054: Unknown column 'Subcat.cat_id' in 'where clause'"
LocalInfosController::admin_index() - APP/controllers/
local_infos_controller.php, line 60
Here's the index function:
function admin_index(){
$this->LocalInfo->bindModel(array('belongsTo'=>array(
'Cat'=>array(
'foreignKey'=>false,
'type'=>'INNER',
'conditions'=>array('Subcat.cat_id = Cat.id')
),
'Location'=>array(
'foreignKey'=>false,
'type'=>'INNER',
'conditions'=>array('LocalInfo.location_id = Location.id')
)
)), false);
$this->set('local', $this->paginate('LocalInfo'));
}
Here are my classes and associations:
class Cat extends AppModel
{
var $name = 'Cat';
var $belongsTo = 'Location';
var $hasMany = array(
'Subcat' => array(
'className' => 'Subcat',
'foreignKey' => 'cat_id'
)
);
}
class Subcat extends AppModel {
var $name = 'Subcat';
var $belongsTo = array(
'Cat' => array(
'className' => 'Cat',
'foreignKey' => 'cat_id'
)
);
var $hasMany = array(
'LocalInfo' => array(
'className' => 'LocalInfo',
'foreignKey' => 'subcat_id'
)
);
}
class LocalInfo extends AppModel
{
var $name = 'LocalInfo';
var $belongsTo = array(
'SubCat' => array(
'className' => 'Subcat',
'foreignKey' => 'subcat_id'
)
);
}
On Feb 16, 1:04 am, WebbedIT <p...@webbedit.co.uk> wrote:
> Something going wrong in your associations or bindings as
> Subcat.cat_id is in a directly related model. Can you supply the
> associations for the model you are running find from, then your
> bindings you are applying, the find command you are running and the
> resulting SQL that it's having problems with?
>
> Paul.
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment