<?php

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

/**
 * Description of GrowthBidRecordOn
 *
 * @author Administrator
 */
class GrowthBidSchoolExpertRecordHistory extends GrowthBidRecord {
    
    public function __construct($table='growth_bid_school_expert_record_history') {
            parent::__construct($table);
    }

    public function save($fieldData) {
        if(array_key_exists('broker_id', $fieldData)&&
                array_key_exists('bid_id', $fieldData)&&
                array_key_exists('school_id', $fieldData)) {
            $brokerId = $fieldData['broker_id'];
            $bidId = $fieldData['bid_id'];
            $schoolId = $fieldData['school_id'];
            $record = $this->findOneBy($brokerId, $bidId, $schoolId);
            if($record) {
                $conf = "broker_id='$brokerId' and bid_id='$bidId' and school_id='$schoolId'";
                $this->update($fieldData, $conf);
                return $this->db->Affected_Rows();
            } else {
                $this->insert($fieldData);
                return $this->db->Affected_Rows();
            }
        } else {
            return false;
        }
        
    }
}

?>
