mysql, fetch array in plugin?

Discussion in 'Plugin Development' started by Subtelny, Nov 15, 2014.

Thread Status:
Not open for further replies.
  1. Hello
    Someone can change this php code to java?

    Code:
    $sql = "SELECT * FROM island_stats ORDER BY points DESC LIMIT 10";
    $result = mysql_query($sql);
     
    $row = mysql_fetch_array($result);
    echo $row['0']. " - ". $row['1'];
    echo "<br />";
     
  2. Offline

    Skionz

    We won't spoon-feed you. Use the built in JDBC API.
     
  3. Just tell me how to convert this:
    Code:
    $row = mysql_fetch_array($result);
    i searched internet and nothing :/
     
  4. Offline

    Skionz

    Subtelny I am not fluent in PHP so I would just read through the javadocs for the JDBC API. I am pretty sure you won't find a PHP to Java compiler.
     
  5. Offline

    Konato_K

    Subtelny Why don't you instead of looking for a translation look for the way to get things in Java instead?

    I found this in one of my plugins

    Code:
       preparedStatement = connection.prepareStatement(queryBuilder.toString());
       preparedStatement.setString(1, player.getName());
       resultSet = preparedStatement.executeQuery();
       if(resultSet!=null && resultSet.next())
       { player.setKills(resultSet.getInt("kills"));
         player.setDeaths(resultSet.getInt("deaths"));
         player.setGamesPlayed(resultSet.getInt("games_played"));
       }
    
     
    Subtelny likes this.
  6. Offline

    mythbusterma



    Certainly I can tell you how to do that.

    Create a result set of the results you want, then

    ResultSet#next()
     
    Subtelny likes this.
  7. Oh it works!!!!

    Thanks guys :)
     
Thread Status:
Not open for further replies.

Share This Page