久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 cakephp 中,如何使用相關(guān)字段的條件進(jìn)行查找

In cakephp how can I do a find with conditions on a related field?(在 cakephp 中,如何使用相關(guān)字段的條件進(jìn)行查找?)
本文介紹了在 cakephp 中,如何使用相關(guān)字段的條件進(jìn)行查找?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我有一個(gè)模型(列表),它擁有并屬于幾個(gè)不同的模型,我想找到所有這個(gè)模型,它的相關(guān)模型(Openhouses)有一個(gè)條件.擁有和屬于"在模型文件中設(shè)置.Listings has many Openhouses 和 Openhouses 屬于 Listings.(并且列表中有很多并且屬于我想要數(shù)據(jù)的其他一些模型.)

I've got a model (Listings) that has and belongs to a few different models, I'd like to find all of this model where it's related model (Openhouses) have a condition. The 'has and belongs to' are setup in the model files. Listings hasmany Openhouses and Openhouses belong to Listings. (And listings has many and blongs to a few other models where I want the data.)

我一直在努力.

$this->Listing->find('all', 
array('conditions' => 
array('Openhouse.date >' => $openhouse_start->format('Y-m-d H:i:s'),
'Openhouse.date <' => $openhouse_end->format('Y-m-d H:i:s'))
));

但無(wú)濟(jì)于事.

Error: 1054: Unknown column 'Openhouse.date' in 'where clause

我知道我可以搜索 Openhouse 模型并獲取相關(guān)列表,但隨后數(shù)據(jù)以不同的格式返回,我需要使用遞歸方式從我的其他模型中獲取數(shù)據(jù).(我最終得到了重復(fù)的開(kāi)放日數(shù)據(jù)!).如果需要,我可以發(fā)布更多代碼示例.

I know I can search on the Openhouse model and get related Listings but then the data is returned in a different format and I need to turn recursion way up to get data from my other models. (And I end up with duplicate openhouse data!). I can post some more code examples if needed.

我的問(wèn)題基本上是我只需要查詢 openhouse 模型并接受它,還是我在相關(guān)模型上放置條件的語(yǔ)法不正確?

My question is basically do I need to just query the openhouse model and live with it or is my syntax for putting conditions on related models incorrect?

推薦答案

試試這個(gè):

$this->List->find('all', array(
    'contain' => array(
        'Openhouse.conditions' => array(
            'Openhouse.date >' => $openhouse_start->format('Y-m-d H:i:s'),
            'Openhouse.date <' => $openhouse_end->format('Y-m-d H:i:s'))
        )
    )
)

這篇關(guān)于在 cakephp 中,如何使用相關(guān)字段的條件進(jìn)行查找?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Session is lost after an OAuth redirect(OAuth 重定向后會(huì)話丟失)
Pagination Sort in Cakephp 3.x(Cakephp 3.x 中的分頁(yè)排序)
CakePHP Shared core for multiple apps(CakePHP 多個(gè)應(yīng)用程序的共享核心)
Login [ Auth-gt;identify() ] always false on CakePHP 3(在 CakePHP 3 上登錄 [ Auth-identify() ] 始終為 false)
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 87 bytes)(致命錯(cuò)誤:允許的內(nèi)存大小為 134217728 字節(jié)已用盡(嘗試分配 87 字節(jié)))
主站蜘蛛池模板: 精品一区二区三区电影 | 91免费视频 | 欧美在线精品一区 | 久久久久国产一区二区三区四区 | 久久久久久久一区二区三区 | 毛片韩国 | 欧美精品一区二区三区四区 在线 | 操久久 | 精品日韩在线 | 久久国内 | 亚洲精品欧洲 | 成人免费共享视频 | 亚洲精品日韩精品 | 日韩欧美在线观看 | 夜色www国产精品资源站 | 亚洲高清久久 | 国产精品久久久久久久久久免费看 | 欧美一级久久 | 日本天堂一区二区 | 国偷自产av一区二区三区 | 中文字幕视频一区二区 | 天天射网站 | 精品九九久久 | 日韩精品在线播放 | 国产精品夜间视频香蕉 | 欧美影院 | 婷婷开心激情综合五月天 | 亚洲永久字幕 | 中文字幕丁香5月 | 国产精品久久99 | 欧美一级观看 | 国产高清精品一区二区三区 | 精品国产一区二区三区在线观看 | 成人三区四区 | 免费观看色 | 男女网站在线观看 | 欧美国产日韩一区二区三区 | 91精品国产综合久久久久久 | 欧美亚洲综合久久 | 日韩免费视频 | 中文字幕一区二区三区四区五区 |