/**
  * insert/update a new entry in the database.
  *
  * @param array $params (reference), array $ids
  *
  * @return object CRM_Price_DAO_PriceFieldValue object
  * @access public
  * @static
  */
 static function &add(&$params, $ids)
 {
     $fieldValueBAO = new CRM_Price_BAO_PriceFieldValue();
     $fieldValueBAO->copyValues($params);
     if ($id = CRM_Utils_Array::value('id', $ids)) {
         $fieldValueBAO->id = $id;
     }
     if (CRM_Utils_Array::value('is_default', $params)) {
         $query = 'UPDATE civicrm_price_field_value SET is_default = 0 WHERE  price_field_id = %1';
         $p = array(1 => array($params['price_field_id'], 'Integer'));
         CRM_Core_DAO::executeQuery($query, $p);
     }
     $fieldValueBAO->save();
     return $fieldValueBAO;
 }
 /**
  * Insert/update a new entry in the database.
  *
  * @param array $params
  *   (reference), array $ids.
  *
  * @param $ids
  *
  * @return CRM_Price_DAO_PriceFieldValue
  */
 public static function add(&$params, $ids = array())
 {
     $fieldValueBAO = new CRM_Price_BAO_PriceFieldValue();
     $fieldValueBAO->copyValues($params);
     if ($id = CRM_Utils_Array::value('id', $ids)) {
         $fieldValueBAO->id = $id;
     }
     if (!empty($params['is_default'])) {
         $query = 'UPDATE civicrm_price_field_value SET is_default = 0 WHERE  price_field_id = %1';
         $p = array(1 => array($params['price_field_id'], 'Integer'));
         CRM_Core_DAO::executeQuery($query, $p);
     }
     $fieldValueBAO->save();
     // Reset the cached values in this function.
     CRM_Price_BAO_PriceField::getOptions(CRM_Utils_Array::value('price_field_id', $params), FALSE, TRUE);
     return $fieldValueBAO;
 }