在这种情况下如何使用getCollection()

I've got this problem that I can't solve. Partly because I can't explain it with the right terms. I'm new to this so sorry for this clumsy question.

Below you can see an overview of my goal.

I'm using Magento CE 1.7.0.2.

i created one module everything is working fine,But i'm having the problem with getCollection().

$attrid = 64;
$collection = Mage::getModel('module/xyz')->getCollection()->addFieldToFilter('c_id',$attrid);

it is working if i have only one record in table for this condition where c_id = $attrid

but actually where c_id = $attrid i'm going to have multiple records at that time its giving the following error

a:5:{i:0;s:74:"Item (Namespace_Module_Model_Xyz) with the same id "64" already exist";i:1;s:6099:"#0 /var/www/com2/lib/Varien/Data/Collection/Db.php(576): Varien_Data_Collection->addItem(Object(Namespace_Module_Model_Xyz))

Also i tried like this

$collection->addFieldToFilter(array(
    ->addFieldToFilter('c_id', array('eq'=>$attrid)
));

Table1 (c_id is Primary Key)

c_id    title    value
-----   -----    -----
 64      my       1

Table2 (autoc_id is Primary Key)

autoc_id     c1      c2     c3      c4      c-id
--------    ----    ----   ----    ----     ----
1           a1       b1     c1      d1      64
2           a2       b2     c2      d2      64
3           a3       b3     c3      d3      64
4           a4       b4     c4      d4      64

config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Namespace_Module>
            <version>0.1.0</version>
        </Namespace_Module>
    </modules>
    <frontend>
        <routers>
            <module>
                <use>standard</use>
                <args>
                    <module>Namespace_Module</module>
                    <frontName>module</frontName>
                </args>
            </module>
        </routers>
        <layout>
            <updates>
                <module>
                    <file>module.xml</file>
                </module>
            </updates>
        </layout>
    </frontend>
    <admin>
        <routers>
            <module>
                <use>admin</use>
                <args>
                    <module>Namespace_Module</module>
                    <frontName>module</frontName>
                </args>
            </module>
        </routers>
    </admin>
    <adminhtml>
        <menu>
            <module module="module">
                <title>Title</title>
                <sort_order>71</sort_order>               
                <children>
                    <items module="module">
                        <title>title2</title>
                        <sort_order>0</sort_order>
                        <action>module/adminhtml_module</action>
                    </items>
                </children>
            </module>
        </menu>
        <acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>
                <admin>
                    <children>
                        <Namespace_Module>
                            <title>Title Module</title>
                            <sort_order>10</sort_order>
                        </Namespace_Module>
                    </children>
                </admin>
            </resources>
        </acl>
        <layout>
            <updates>
                <module>
                    <file>module.xml</file>
                </module>
            </updates>
        </layout>
    </adminhtml>
<global>
        <models>
            <module>
                <class>Namespace_Module_Model</class>
                <resourceModel>module_mysql4</resourceModel>
            </module>
            <module_mysql4>
                <class>Namespace_Module_Model_Mysql4</class>
                <entities>
                    <module>
                        <table>table1</table>
                    </module>
                </entities>
                <entities>
                    <flatrates>
                        <table>table2</table>
                    </flatrates>
                </entities>
            </module_mysql4>
        </models>
        <resources>
            <module_setup>
                <setup>
                    <module>Namespace_Module</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </module_setup>
            <module_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </module_write>
            <module_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </module_read>
        </resources>
        <blocks>
            <module>
                <class>Namespace_Module_Block</class>
            </module>
        </blocks>
        <helpers>
            <module>
                <class>Namespace_Module_Helper</class>
            </module>
        </helpers>
    </global>
</config>

But nothing use still i have same problem

Anything wrong i did here

Any ideas ?

Have you tried checking whether the records on your table have the same id? I have tried looking on that particular code on the core library and found out items on a collection must have unique ids or else it throws an exception.

<?php
public function addItem(Varien_Object $item)
{
    $itemId = $this->_getItemId($item);

    if (!is_null($itemId)) {
        if (isset($this->_items[$itemId])) {
            throw new Exception('Item ('.get_class($item).') with the same id "'.$item->getId().'" already exist');
        }
        $this->_items[$itemId] = $item;
    } else {
        $this->_addItem($item);
    }
    return $this;
}

Its seem to have something to do with your primary keys, double check the _init() setting in your model since it using the wrong column for your primary key.

class MagePal_Module_Model_Mysql4_Xyx extends Mage_Core_Model_Mysql4_Abstract
{
    public function _construct()
    {   
        $this->_init('module/xyz', 'autoc_id');