public function addAssociation($assoc)
    {
        $where = "";
        if ($assoc["Relationship"] == "1-M" || $assoc["Relationship"] == "M-1" || $assoc["Relationship"] == "1-1")
        {
            // assc table should same as maintable
            if ($assoc["Table"] != $this->_mainTable) return;
            // add table to join table
            $mytable_col = $this->getTableColumn(null, $assoc["Column"]);
            // construct table.column = 'field value'
            $where = $mytable_col." = '".$assoc["FieldRefVal"]."'";
            
            $mytable_col2 = $this->getTableColumn(null, $assoc["Column2"]);
            if($assoc["Column2"]){
            	$where .= " AND ".$mytable_col2." = '".$assoc["FieldRefVal2"]."'";
            }
            $mytable_cond_col = $this->getTableColumn(null, $assoc["CondColumn"]);
            if($assoc["CondColumn"]){
            	$where .= " AND $mytable_cond_col ='".$assoc["CondValue"]."' ";
            }
        	if($assoc["Condition"]){
            	$where .= " AND ".$assoc["Condition"]." ";
            }
        }
        elseif ($assoc["Relationship"] == "M-M" || $assoc["Relationship"] == "Self-Self")
        {
            // ... INNER JOIN xtable TX ON TX.column2 = T0.column
            // WHERE ... Tx.column1 = 'PrtTableColumnValue'
            $mytable_col = $this->getTableColumn(null, $assoc["Column"]);   // this table's alias.column
            $xtable = $assoc["XTable"];    // xtable's name
            $column1 = $assoc["XColumn1"]; // xtable column1
            $column2 = $assoc["XColumn2"]; // xtable column2
            $xalias = "TX";
            if (isset($this->_tableAliasList[$xtable]))
                $xalias = $this->_tableAliasList[$xtable];

            // add a table join for the xtable if such join of the table is not there before (note: may report error if has same join).
            //if (strpos($this->tableJoins, "JOIN $xtable") === false)
            if (!isset($this->_tableAliasList[$xtable]))
            {
                $this->_tableJoins .= " INNER JOIN `$xtable` $xalias ON $xalias.$column2 = $mytable_col ";
                $this->_tableAliasList[$xtable] = $xalias;
            }
            
            // add a new where condition
            if($assoc["Relationship"] == "Self-Self")
            {   
            	$columnId = $this->getTableColumn("", $assoc["ParentRecordIdColumn"]);             	
            	$where = "($xalias.$column1 = '".$assoc["FieldRefVal"]."' OR $xalias.$column2 = '".$assoc["FieldRefVal"]."' ) AND $columnId != '".$assoc["FieldRefVal"]."'";
            	$this->_tableJoins .=  " OR $xalias.$column1 = $mytable_col ";
            }else{
            	$where = "$xalias.$column1 = '".$assoc["FieldRefVal"]."'";
            }
        }

        if (strlen($where) > 1)
            $this->addSqlWhere($where);
    }