<?php

require_once '../RitoConnecter.php';
require_once '../DBConnecter.php';
require_once '../config.php';
set_time_limit(0);
// connect to database
$db = new SQLConnecter($db_host, $db_username, $db_pass, $db_name, $db_port);
$dbh = $db->connect();
// set item list URL
$rito = new RitoConnecter($region, $api_key, $game, $champ, $items);
$url = $rito->items_url();
echo $url, '<br>';
// get item list
$raw = $rito->get_content($url);
$jso = json_decode($raw, true);
// populate item table
foreach ($jso['data'] as $obj) {
    $id = $obj['id'];
    $name = $obj['name'];
    if (isset($obj['stats']['FlatMagicDamageMod'])) {
        $ap = $obj['stats']['FlatMagicDamageMod'];
    } else {
        $ap = 0;
    }
    $qry = 'INSERT INTO `items` (`ItemID`, `ItemName`, `AP`) VALUES (' . $id . ', "' . $name . '", ' . $ap . ');';
    $result = $dbh->query($qry);
    echo $qry, '<br>';
}
$dbh->close();
<?php

require '../RitoConnecter.php';
require '../DBConnecter.php';
require '../config.php';
set_time_limit(0);
// connect to database
$db = new SQLConnecter($db_host, $db_username, $db_pass, $db_name, $db_port);
$dbh = $db->connect();
// set champion URL
$rito = new RitoConnecter($region, $api_key, $game, $champ, $items);
$url = $rito->champ_url();
echo $url, '<br>';
// get champion list
$data = $rito->get_content($url);
$jso = json_decode($data, true);
// populate champ table
foreach ($jso['data'] as $obj) {
    $id = $obj['id'];
    $name = $obj['key'];
    $qry = 'INSERT INTO `champions` (`ID`, `Name`) VALUES (' . $id . ', "' . $name . '");';
    $result = $dbh->query($qry);
    echo $qry, '<br>';
}
$dbh->close();