Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6032667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:22:04+00:00 2026-05-23T05:22:04+00:00

My shopping app needs to do currency conversion, my plan is to use a

  • 0

My shopping app needs to do currency conversion, my plan is to use a crontab to grab the latest exchange rates once an hour. My question is whats the best way to store and use this in my CI application. Should I:
– Write it to the DB everytime its run and then grab the rate from the DB evrytime i need to do a conversion
– Do the same but with a text file
– Write it to a constant in the index.php
– Some sort of core or hook file

Whats the most efficient way

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:22:05+00:00Added an answer on May 23, 2026 at 5:22 am

    The quick & dirty way would be writing a PHP file with the said currencies. You can use var_export() to save them safely.

    Config:

    $file = '/path/to/currencies.php';
    

    Cronjob:

    // get data from API (note: you should use proper functions via CURL)
    $currencies = file_get_contents('http://some.api.com/currencies');
    // decode data
    $currencies = json_decode( currencies );
    // export data into PHP format
    $currencies = var_export( currencies, true );
    // save to file
    file_put_contents($file, "<?php\r\n $currencies=".$currencies."; \r\n?>");
    

    Currency Page:

    // ensure you get a default something
    $currencies = array();
    // load data file (note, we use include so we can load it whenever we want)
    @include $file;
    // output something from array
    echo $currencies['EUR'];
    

    Note that we don’t even connect to DB anywhere, making this very fast. There is also no parsing/conversion. With the DB concept, you have to at least loop over the database rows. Using a normal config medium, such as ini, json or xml files would requiring some form of parsing after PHP loads. Whereas, with this method, it is a part of PHP’s loading process; you’re just including a small PHP file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a .NET WinForms app that needs to print a FEDEX shipping
I'm making a shopping cart app in Google App Engine. I have many classes
Or vice versa. Update: Hmm, let's assume I have a shopping cart app, the
I'm writing a silverlight application that resembles a shopping cart system. This app can
i want to use shopping cart in my portal. can i get shopping cart
We are developing a django app for several restaurants, it's like a shopping chart.
I'm making a shopping list app which basically uploads your shopping list to a
Im making a little shopping list app. In the app, if an item in
I have a shopping cart in my app. I also have a UIBarButton called
I have build an app that use mp3-files. In the first version the files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.