Bin will be removed on June 1, 2014 in favor of http://gist.github.com. Please save all your pastes before then. So long, and thanks for all the fish!×
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/models/theme.php
=================
class Theme extends AppModel {
    var $name = 'Theme';
   
    var $hasMany = array('Comment');
    var $belongsTo = 'User';
    var $hasAndBelongsToMany = array('Tag');
...
..
}
 
/models/tag.php
================
class Tag extends AppModel {
    var $name = 'Tag';
    var $hasAndBelongsToMany = array('Theme');
}
 
/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?