English 中文(简体)
兼容的模型结果
原标题:Filtering Containable Model Results

我正试图用以下的法典行文来过滤“谁”的“谁”具有某些(无关的)条件的所有员额。

c 美元=6美元;

然而,我不是仅仅在标的岗位上才有结果,而是在没有“谁”的帽子上,每个职位都有空档。

I know my question has come up before, but the solutions posted have not worked with my code. I have tried adapting the code here to my own: http://web-development-blog.co.uk/2010/09/14/cakephp-habtm-find-with-conditions-and-containable-behavior/, but I get an SQL error stating "Tag.post_id" not found in on clause.

请提供帮助。

试图从某些链接中执行守则的错误信息:

SELECT `Post`.`id`, `Post`.`title`, `Post`.`body`, `Post`.`created`,       `Post`.`modified`, `Tag`.`id`, `Tag`.`tag`, `Tag`.`created`, `Tag`.`modified` FROM `posts` AS `Post` LEFT JOIN `tags` AS `Tag` ON (`Tag`.`post_id` = `Post`.`id`) WHERE `Tag`.`tag` =  who     1054: Unknown column  Tag.post_id  in  on clause             

原因如下:

$this->Post->bindModel(array( hasOne  => array( Tag )));
$this->Post->contain(array(
   Tag 
));
$com=$this->Post->find( all , array(
   conditions =>array( Tag.tag => who ) 
)); 
问题回答

你的错误是,你正在使用束缚式的阴道,说出外国钥匙或东西,你在模式上建立了协会,并在严格需要时使用这种手法。

you need to tell cake which foreignkey of not cake will use the default, in your case it will try Tag.post_id.

Also you should use a has many association or at least i think so. I said this beacause i suppose a post may have multiple tags.

一俟您在模型中统一,删除这一行文

(a) bin; 1 => 阵列(Tag));

it should work perfectly

http://book.cakephp。

EDIT:

职业介绍会读写错误...... 有许多协会没有加入,因此,你必须使用其中的文字来说明该联合会的状况或附加条件,这里指的是,你的法典应如何考虑添加包含条件的条件。

$contain = array(
   Tag  => array(
        conditions => array( Tag.tag => who ) 
   )
);
$com=$this->Post->find( all , array(
   contain =>$contain 
));

会员资格包含超越协会条件的条件! 如果你想有额外条件,你就必须在这样的传单上加添:

$this->Post->hasMany[ Tag ][ conditions ] += array( Tag.tag => who );

将传单上的协会改名为“光顾”组织。

Also you may do a hasmany alias for different types (remember to define always the classname and foreignkey).

希望它能发挥这一作用,甚至不只评论看它的位置。





相关问题
Search field with Thickbox issue

i have a search form which is shown with Thickbox inside an iframe. the problem is.. that after i click "search" the result page is shown inside the same iframe! and i want it to be shown in the main ...

Will an incomplete google sitemap hurt my search ranking?

If I submit a sitemap.xml which does not contain all of the pages of my site, will this affect my search ranking? For example: If my sitemap only contained pages that had been created in the last ...

speeding up windows file search with C#

i made a program that search logical drives to find a specific file .if user type file name an click search button , searching begins , but i don t know how to stop searching in the middle of process....

JQuery/MVC Search Issue

I have inherited a piece of work where the entry screen shows a summary of 20 calculated variables. E.g. Var A (250), Var B (79). Clicking on any of these links takes the user to a view with a ...

Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Search by using the keyboard in a list/grid - algorithm

I need to implement a custom search in a grid and I would like to find some user interface guidelines that explain the standard way to implement it. I mean this kind of search that is initiated by ...

Embed Google/ Yahoo search into a web site or build your own

I am looking for an opinion on the whether to use Google custom search, Yahoo search builder or build my own for web projects (no more than 100 pages of content). If I should build my own - do you ...

热门标签