随处运行,如之前写的《magento基础的增删改查操作》一样。
/**
* 功能:SELECT count(*) as attribute_num,entity_type_id FROM eav_attribute where is_required = 1 group by entity_type_id limit 0,1;
*/
public function groupTestFn() {
//获得eav_attribute这个表
$table = Mage::getSingleton('core/resource')->getTableName('eav_attribute');
//建立连接
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
//执行操作
$select = $connection->select()
->from($table, array('COUNT(*) AS attribute_num', $table . '.entity_type_id'))
->where($table . '.is_required=?', '1')
->group($table . '.entity_type_id');
$data = $connection->fetchRow($select);
return $data;
}