magento 的一些关于addFieldToFilter的查询
生活随笔
收集整理的這篇文章主要介紹了
magento 的一些关于addFieldToFilter的查询
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1,匹配country_id的首字母,查詢國家,返回數(shù)組
//查詢國家數(shù)據(jù)集$countryCollection=Mage::getResourceModel('directory/country_collection')->addFieldToFilter('country_id',array('like'=>'A%'));$countryList=$countryCollection ->loadData()->toOptionArray(false);var_dump($countryList);2,關(guān)于查詢用戶的數(shù)據(jù)集
//用戶數(shù)據(jù)集查詢$emailString='linda@eprid.com,getupc05@sina.com,getupc10@sina.com';$customerCollection=Mage::getModel('customer/customer')->getCollection()// 查詢某個用戶// ->addAttributeToFilter('email','linda@eprid.com')//根據(jù)郵箱地址,查詢字符串里面的用戶->addAttributeToFilter('email',array('in'=>$emailString));//按照eva中實體的id進行降序排序,并返回前五個 /* ->addAttributeToSort ( 'entity_id', 'desc' )->setPageSize(5);*/2,關(guān)于產(chǎn)品數(shù)據(jù)集的查詢
//產(chǎn)品數(shù)據(jù)集查詢$productCollection=Mage::getModel('catalog/product')//根據(jù)產(chǎn)品id返回對應(yīng)產(chǎn)品數(shù)據(jù)集對象->load(2);//輸出執(zhí)行當前查詢sql語句/* $productCollection->getSelect();*///遍歷數(shù)據(jù)集,并返回產(chǎn)品名稱foreach($productCollection as $product){echo $product->getName();}?
轉(zhuǎn)載于:https://www.cnblogs.com/liangsongbai/p/5511360.html
總結(jié)
以上是生活随笔為你收集整理的magento 的一些关于addFieldToFilter的查询的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android中ListView控件on
- 下一篇: 两种方法设置disabled属性