magento--------------数据库操作

1
 $collection = Mage::getModel('catalog/product')->getCollection(); 
      $collection->getSelect()->where('e.entity_id in (?)', $ids); 
      $collection->addAttributeToSelect('*');
2
 $resource = Mage::getSingleton('core/resource'); 
        $read = $resource->getConnection('catalog_read');

  $select = $read->select() 
                       ->from(array('cp'=>$categoryProductTable))
3
 $categoryProductTable = $resource->getTableName('catalog/category_product');
4
 $productEntityIntTable = (string)Mage::getConfig()->getTablePrefix().
5

通过读写适配器得到的是:
Varien_Db_Adapter_Pdo_Mysql extends Zend_Db_Adapter_Pdo_Mysql
然后通过select()方法得到的是:Varien_Db_Select extends Zend_Db_Select

 $select = $this->_getReadAdapter()->select()
            ->from($this->getTable('store'))
            ->where('post_id = ?', $object->getId());


  protected function _getReadAdapter()
    {
        return $this->_getConnection('read');
    }


也就是说通过collection->getSelect()和
Mage::getSingleton('core/resource')->getConnection('catalog_read')->select()得到的都是Varien_Db_Select extends Zend_Db_Select

 

故。。。。。。。。。。。很好使用,看好Varien_Db_Select 和Zend_Db_Select的方法,就可以随意的使用已经封装好的函数!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

你可能感兴趣的:(magento--------------数据库操作)