<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of GrowthBidRecordOn
 *
 * @author Administrator
 */
class GrowthBidBlockExpertRecordOn extends GrowthBidRecord {
    
    public function save($fieldData) {
        if(array_key_exists('broker_id', $fieldData)&&
                array_key_exists('bid_id', $fieldData)&&
                array_key_exists('house_id', $fieldData)) {
            $brokerId = $fieldData['broker_id'];
            $bidId = $fieldData['bid_id'];
            $houseId = $fieldData['house_id'];
            $record = $this->findOneBy($brokerId, $bidId, $houseId);
            if($record) {
                $conf = "broker_id='$brokerId' and bid_id='$bidId' and house_id='$houseId'";
                $this->update($fieldData, $conf);
                return $this->db->Affected_Rows();
            } else {
                $this->insert($fieldData);
                return $this->db->Affected_Rows();
            }
        } else {
            return false;
        }
        
    }
    public function findOneBy($brokerId,$bidId,$houseId=0) {
        $sql = SqlCombinHelper::select_sql($this->table, $this->fields,"broker_id='$brokerId' and bid_id='$bidId'");
        return $this->dbback->getRow($sql);
    }
}

?>
