Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to know if a row is already occupied. SQLite3 issue

Comments in 'Plugin Development' started by Hotshot_9930, Sep 12, 2015.

  1. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Im trying to find out if a row already has something in it, if it doesnt the plugin will insert something. If it already has something in it, nothing is supposed to happen.
    My current code (Which doesnt work):
    PHP:
    public function createPlayerData($player$playername) {
             
    $player->sendMessage("Creating player data...");
             
    $stmt $this->db->prepare("INSERT INTO kills (player, amount) VALUES (:playername, 0) WHERE NOT EXISTS(SELECT amount FROM kills WHERE 'player' = :playername);");
             
    $stmt->bindValue(":playername"$playername);
             
    $stmt->execute();
    Im still a SQLite3 noob, so any help would be appreciated
  2. basprohop
    Offline

    basprohop Active Member Plugin Developer

    Joined:
    Aug 8, 2015
    Posts:
    128
    Plugins:
    3
    Minecraft User:
    basprohop
    Andrey Nazarchuk likes this.
  3. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
  4. basprohop
    Offline

    basprohop Active Member Plugin Developer

    Joined:
    Aug 8, 2015
    Posts:
    128
    Plugins:
    3
    Minecraft User:
    basprohop
    Anytime :)
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    SELECT COUNT(*) FROM `table` WHERE conditions

Share This Page

Advertisement