Skip to main content
5 of 6
added 230 characters in body
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239

in Model/Mysql4/Modulename.php

Mage_Core_Model_Mysql4_Collection_Abstract 

Should be:

Mage_Core_Model_Mysql4_Abstract

How to create database module:http://www.amitbera.com/create-an-magento-extension-with-custom-database-table/

Try This

$Collection=Mage::getModel('module/model')->getCollection()->addFieldToFilter('customer_id',$customerId)->addFieldToSelect('*')->setOrder('order_id',DESC);

$collection give array of Record of customer Id

for get one item try this

$Collection->getFirstItem();

EDIT Code for

public function addCustomFilter($customerId =null){
        $this->getSelect()->where("customer_id =?",$customerId) ->order('order_id ' . Varien_Db_Select::SQL_DESC);
        reeturn $this;
        }
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239