Jump to content

How to handle large amounts of data?


Chris Rosenau
 Share

Recommended Posts

Problem:

I want to have states and each state I want to have cities. I really don't want to make a page for each city as it is very very time consuming the way the system is designed. There are hundreds of cities for each state. So the module field type select seems like an ok option, but I read that it isn't normalized so data could get corrupt. I also wonder about limited ability to search that data with current built in functions like $page->find.

Can anyone give me advice on how to deal with large amounts of data?

Thanks!

Link to comment
Share on other sites

you could import from a csv into pages

if you're just using them as selects for example you could store all of the data in 1 text field.. and then use php to make the list into options

you could also consider storing in a static file, xml or json, or xml/json in a field

it really depends on what you need to do with this data

Link to comment
Share on other sites

I would go the pages & API route, it's very quick!

You could make a big array & loop it:

$cities = array(
    'Albany, NY',
    'Albuquerque, NM',
    'Anchorage, AK',
    'Annapolis, MD',
    'Atlanta, GA',
    'and',
    'continue',
    'the',
    'list',
    .....
);

$parent = $pages->get('/cities/'); // assumed that you have a cities parent.

foreach($cities as $city) {
    $p = new Page;
    $p->parent = $parent;
    $p->template = 'city'; // choose a valid template for this
    $p->title = $city;
    $p->save();
}

(written in the browser, but simular concept I have used often)

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...