I have two models which are associated with each other as follows:

// This is our Content File Catalog Model Class

class ContentFileCatalog extends AppModel
{
    var $hasMany = array('ContentFileCatalogComment' =>
                        array('className'               => 
'ContentFileCatalogComment',
                         'conditions'                   => '',
                         'order'                        => '',
                         'foreignKey'                   => 
'content_file_catalog_id'
                         )
                  );

}




// This is our Content File Catalog Comment Model Class

class ContentFileCatalogComment extends AppModel
{
    var $belongsTo = array('ContentFileCatalog' =>
                        array('className'               => 'ContentFileCatalog',
                         'conditions'                   => '',
                         'order'                        => '',
                         'foreignKey'                   => 
'content_file_catalog_id'
                         )
                  );

}


Now, I am executing a FindAll() query in my conrtoller for the first
model as follows:

// This is our Content File Catalog Controller Class

class ContentFileCatalogController extends AppController
{

   function GetCommentByContentFileCatalogID($blnFunctionCallWS="",
$intContentFileCatalogID="",$strLoggingData="")
        {
                if($blnFunctionCallWS)
                {
                        $condition = "where
ContentFileCatalog.id='$intContentFileCatalogID'";
                        $fields =
array("ContentFileCatalog.id","ContentFileCatalogComment.comment");
                        
$this->set('Result',$this->ContentFileCatalog->findAll($condition,
$fields));
                }
        }
}


The problem I am having is that it does not execute a join between the
two Models based on the associations between them - it just considers
the ContentFileCatalog model and ignores the ContentFileCatalogComment
Model.

The SQL error that shows up is as follows:

--"Unknown column 'ContentFileCatalogComment.comment' in 'field
list'"--

and the Query that is executed is as follows:

Query : SELECT `ContentFileCatalog`.`id`,
`ContentFileCatalogComment`.`comment` FROM `content_file_catalogs` AS
`ContentFileCatalog` where `ContentFileCatalog`.`id`='1'



However, if I am to change the 'hasMany' association in the first
Model 'ContentFileCatalog'  to a 'hasOne', it executes the join and
the results are returned correctly  - but the actual association that
should exist between the two Model is 'hasMany'


I am using Cake 1.20+ and running on LAMPHP setup.

any help would be greatly appreciated - thanks

-Ankur


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to