有用的Magento Collection函数
来源:互联网 发布:怎样用matlab编程 编辑:程序博客网 时间:2024/04/30 22:25
There are different important functions that you can implement in your Collection object. The functions are present in Varien_Data_Collection_Db class. The class file is present in lib/Varien/Data/Collection/Db.php
Here are some of the functions that you can use in your collection object:-
/**
* Get Zend_Db_Select instance
*/
$collection->getSelect();
/**
* Get collection size
*/
$collection->getSelect()->getSize();
/**
* Get sql select string or object
*/
$collection->getSelect()->getSelectSql();
/**
* Add select order
*/
$collection->getSelect()->setOrder($field, $direction);
/**
* Add field filter to collection
*
* If $attribute is an array will add OR condition with following format:
* array(
* array(‘attribute’=>’firstname’, ‘like’=>’test%’),
* array(‘attribute’=>’lastname’, ‘like’=>’test%’),
* )
*/
$collection->getSelect()->setOrder($field, $condition);
/**
* Set select distinct
*/
$collection->getSelect()->distinct($flag);
/**
* Get all data array for collection
*/
$collection->getSelect()->getData();
/**
* Reset loaded for collection data array
*/
$collection->getSelect()->resetData();
/**
* Print and/or log query
*/
$collection->getSelect()->printLogQuery(true, true);
More functions below:-
Varien_Data_Collection_Db class extends Varien_Data_Collection class. Here are some more functions present in Varien_Data_Collection class:-/**
* Get current collection page
*/
$collection->getSelect()->getCurPage();
/**
* Retrieve collection last page number
*/
$collection->getSelect()->getLastPageNumber();
/**
* Retrieve collection page size
*/
$collection->getSelect()->getPageSize();
/**
* Retrieve collection all items count
*/
$collection->getSelect()->getSize();
/**
* Retrieve collection first item
*/
$collection->getSelect()->getFirstItem();
/**
* Retrieve collection last item
*/
$collection->getSelect()->getLastItem();
/**
* Retrieve collection items
*/
$collection->getSelect()->getItems();
/**
* Clear collection
*/
$collection->getSelect()->clear();
You can also use the select functions as present in Zend_Db_Select class. This class file is present in lib/Zend/Db/Select.php
Hope this helps. Thanks.
来自:http://blog.chapagain.com.np/magento-collection-functions/
- 有用的Magento Collection函数
- 关于magento collection的join
- magento collection
- Magento获取当前Collection的排序方式
- magento中有用的代码片段
- magento中有用的代码片段
- magento中有用的代码片段-
- Collection.sort 的用法--很有用哦
- Magento collection filters
- magento collection的dropdown attribute,怎么用text筛选
- magento grid collection 多表查询字段冲突的解决
- Magento getChildHtml函数的使用方法
- magento 模板可用的函数
- 对初学magento开发很有用的原理解析
- 几个很有用的magento模板调试技巧
- 有用的Format函数
- 一些有用的函数
- 有用的php函数
- Rsync命令参数详解
- 关于C# 中的Attribute 特性
- wintegra 芯片的重要组成部分-软件侧
- 通过js,给jsp页面添加表格及数据
- VB.NET 读写ini文件
- 有用的Magento Collection函数
- gcc 的编译选项
- Flixel框架介绍一
- Linux 和 Vxworks 的内存分布-区别与联系
- Flixel介绍二
- XP下安装Linux双系统时停止在ehci问题
- 转 三步让你时间变充裕
- 关于递归效率低的解决方法___SQL递归
- C