public function save($chain_name) { $domain_name = $this->_domain_name; $item_name = $chain_name; $attributes = SimpleDbUtils::genSimpleDbAttributesArray(array("chain_name" => $chain_name)); SimpleDbPersister::save($domain_name, $item_name, $attributes); }
return; } //If a new business entry, check whether it exists already if ($is_update_operation === FALSE && CoreAttributesUtils::exists($data) === TRUE) { $error_json = array("status" => "error", "error" => "Business already exists"); echo json_encode($error_json); return; } //If an update operation, don't re-generate business_id and set $replace to true if ($is_update_operation === TRUE) { $attributes = SimpleDbUtils::genSimpleDbAttributesArray($data, true); } else { $is_busines_id_already_taken = false; /* Check whether the unique business id that is generated is already not * taken. */ do { $business_id = BusinessIdGenerator::generate($data["pincode"]); $data["business_id"] = $business_id; $result = SimpleDbPersister::getAttributes($domain_name, $business_id, array("business_id")); $is_business_id_already_taken = empty($result) ? false : true; } while ($is_business_id_already_taken === TRUE); $attributes = SimpleDbUtils::genSimpleDbAttributesArray($data); } $message = CoreAttributesUtils::generateSMSMessage($data); SMS::send($sms_number, $message); $business_id = $data["business_id"]; SimpleDbPersister::save($domain_name, $business_id, $attributes); $success_json = array("status" => "success", "business_id" => $business_id, "created_by_user" => $data["created_by_user"], "created_time" => $data["created_time"]); echo json_encode($success_json); return;