07.01
php
saved
depinko
Note
Can't get work the HABTM relationship.
Can't get work the HABTM relationship.
- /models/theme.php
- =================
- class Theme extends AppModel {
- var $name = 'Theme';
- var $belongsTo = 'User';
- ...
- ..
- }
- /models/tag.php
- ================
- class Tag extends AppModel {
- var $name = 'Tag';
- }
- /controllers/themes_controller.php
- ==================================
- function index() {
- $this->pageTitle = 'Browse themes';
- $this->set('themes', $this->Theme->find('all'));
- $this->Session->write('redirectTo', '/'.$this->params['controller'].'/'.$this->params['action']);
- }
- OUTPUT from /views/index.ctp:
- =============================
- Warning (512): SQL Error: 1054: Unknown column 'Tag.id' in 'on clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 512]
- Code | Context
- $sql = "SELECT `Tag`.`tag_id`, `Tag`.`name`, `TagsTheme`.`tag_id`, `TagsTheme`.`theme_id` FROM `tags` AS `Tag` JOIN `tags_themes` AS `TagsTheme` ON (`TagsTheme`.`theme_id` IN (1, 2, 3, 4, 5, 6, 7, 13) AND `TagsTheme`.`tag_id` = `Tag`.`id`) WHERE 1 = 1 "
- $error = "1054: Unknown column 'Tag.id' in 'on clause'"
- $out = null
- $out = null;
- if ($error) {
- trigger_error("<span style = \"color:Red;text-align:left\"><b>SQL Error:</b> {$this->error}</span>", E_USER_WARNING);
- DboSource::showQuery() - CORE/cake/libs/model/datasources/dbo_source.php, line 512
- DboSource::execute() - CORE/cake/libs/model/datasources/dbo_source.php, line 202
- DboSource::fetchAll() - CORE/cake/libs/model/datasources/dbo_source.php, line 338
- DboSource::queryAssociation() - CORE/cake/libs/model/datasources/dbo_source.php, line 788
- DboSource::read() - CORE/cake/libs/model/datasources/dbo_source.php, line 653
- Model::find() - CORE/cake/libs/model/model.php, line 1795
- ThemesController::index() - APP/controllers/themes_controller.php, line 13
- Object::dispatchMethod() - CORE/cake/libs/object.php, line 114
- Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 256
- Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 230
- [main] - APP/webroot/index.php, line 84
- Query: SELECT `Tag`.`tag_id`, `Tag`.`name`, `TagsTheme`.`tag_id`, `TagsTheme`.`theme_id` FROM `tags` AS `Tag` JOIN `tags_themes` AS `TagsTheme` ON (`TagsTheme`.`theme_id` IN (1, 2, 3, 4, 5, 6, 7, 13) AND `TagsTheme`.`tag_id` = `Tag`.`id`) WHERE 1 = 1
- I'm missing something?
Parsed in 0.100 seconds, using GeSHi 1.0.7.14