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

過濾 Magento 集合但不過濾產品,使用不同的

Filter Magento collection but not products, using distinct(過濾 Magento 集合但不過濾產品,使用不同的)
本文介紹了過濾 Magento 集合但不過濾產品,使用不同的的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

在我的 magento 商店中,我試圖從數據庫表中檢索 youtube 視頻列表,但有些視頻是重復的.

In my magento store I am trying to retrieve a list of youtube videos from a DB table, some videos are duplicated.

我希望通過使用不同的視頻值"來過濾視頻,但無法找到有關使用 addFieldToFilter() 使用不同的任何信息

I'm looking to filter videos by using distinct video "value" but can't seam to find any information about using distinct with addFieldToFilter()

// get video collection

$collection = Mage::getModel('video/video')->getCollection();
$collection->addFieldToFilter('provider', 'youtube');

// filter by video value

$collection->addFieldToFilter('value')->distinct(true);

通過刪除 $collection->addFieldToFilter('value')->distinct(true); 它可以工作,但會檢索所有視頻.

By removing $collection->addFieldToFilter('value')->distinct(true); it works, but retrieves all the videos.

推薦答案

你可以試試這個:

$collection->getSelect()->distinct(true);

但這將根據 id 檢索不同的值.如果要使用不同的視頻值檢索視頻,則應按值"分組.

But this will retrieve distinct values based on id. If you want to retrieve videos using distinct video values, you should group by "value".

$collection->getSelect()->group('value');

如果要調試執行的查詢:

If you want to debug the query executed :

$collection->getSelect()->__toString();

希望能幫到你

這篇關于過濾 Magento 集合但不過濾產品,使用不同的的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 最新一级毛片 | 亚洲黄色一区二区三区 | 国产在线a视频 | 久久综合一区二区 | 国产精品av久久久久久毛片 | 一区二区精品 | 久久高清精品 | 国产电影一区二区在线观看 | 天天天操 | 色妞av| 新疆少妇videos高潮 | 男女网站在线观看 | 亚洲天堂久久 | 中文字幕黄色大片 | 国产伦精品一区二区 | 在线a视频| 夜夜艹天天干 | 九九九国产 | 91免费在线看 | 日韩精品亚洲专区在线观看 | 国产精品178页 | 国产在线第一页 | 国产aaaaav久久久一区二区 | 成人h视频在线观看 | 亚洲欧美日本在线 | 美女一级a毛片免费观看97 | 五月综合激情在线 | 日本精品一区二区三区在线观看视频 | 一级黄在线观看 | 黑人巨大精品欧美一区二区免费 | 亚洲一区国产精品 | 一道本视频 | 一级做a爰片久久毛片免费看 | 久久综合一区 | 91精品国产91久久综合桃花 | xx视频在线 | 亚洲精品www | 亚洲成人自拍 | 国产精品99视频 | 一区二区三区在线 | 色播av |