Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "root";
- $database = "rathena";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "Connected successfully\n";
- $sql = "SELECT
- id,
- -- UPPER(Sprite) AS Sprite,
- -- UPPER(kName) AS kName,
- UPPER(iName) AS iName ,
- iName AS name,
- LV, HP, SP, EXP, JEXP, Element, MEXP
- FROM `mob_db_re`";
- $stmt = $conn->prepare($sql);
- $stmt->execute();
- $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
- $monsters = $stmt->fetchAll();
- $dataMonsters = [];
- foreach ($monsters as $index => $monster) {
- $dataMonsters[$index]['id'] = $monster['id'];
- // $dataMonsters[$index]['Sprite'] = $monster['Sprite'];
- // $dataMonsters[$index]['kName'] = $monster['kName'];
- $dataMonsters[$index]['iName'] = $monster['iName'];
- $dataMonsters[$index]['name'] = $monster['name'];
- $dataMonsters[$index]['LV'] = $monster['LV'];
- $dataMonsters[$index]['HP'] = $monster['HP'];
- $dataMonsters[$index]['SP'] = $monster['SP'];
- $dataMonsters[$index]['EXP'] = $monster['EXP'];
- $dataMonsters[$index]['JEXP'] = $monster['JEXP'];
- $dataMonsters[$index]['Element'] = $monster['Element'];
- $dataMonsters[$index]['MEXP'] = $monster['MEXP'];
- }
- $jsonMonsters = json_encode($dataMonsters);
- file_put_contents('json/monsters.json', $jsonMonsters);
- // print_r($jsonMonsters);
- } catch(PDOException $e) {
- echo "Connection failed: " . $e->getMessage();
- }
- $conn = null;
Add Comment
Please, Sign In to add comment