A class to add and select players within a database I have a question and want to know if my class is considered object oriented.

class Player {

    private $db

    function __construct($db) {

        $this-&gt;db = $db;

    }

    public function set_player($name, $position, $number, $team) {

        try {

            $sql = 'INSERT INTO players SET playername = :playername, position = :position, teamid = :teamid, jersey = :jersey';
            $this-&gt;db-&gt;prepare($sql);
            $s-&gt;bindValue(':playername', $name);
            $s-&gt;bindValue(':teamid', $team);
            $s-&gt;bindValue(':position', $position);
            $s-&gt;bindValue(':jersey', $number);
            $s-&gt;execute();

        } catch (PDOEXception $e) {

            echo 'Could not add player, please try again.';
            exit();

        }

    }

    public function get_player($id) {

        $result = $this-&gt;db-&gt;query('SELECT * FROM players WHERE id =' . $id);
        $row = $result-&gt;fetch(PDO::FETCH_OBJ);
        return $row;

    }

}


In another file  I will use this class in this way

include_once('./includes/global.php');

$player = new Player($pdo);

$player-&gt;set_player(Chris, Forward, 13, 1);

echo $player-&gt;get_player(1)-&gt;playername;
echo $player-&gt;get_player(1)-&gt;position;
Calling get_player twice is not a good idea, as each time a db query is necessary.

As you are asking about OOP: You could add an actual Player object, which contains playername, position, etc as fields. Your current class could then be renamed PlayerDAO or something, and would then return a player object. 

The main advantage would be that a concrete object is easier to use than an anonymous one (classes are to some degree self-documenting, while you can't be sure what an anonymous object actually contains).

Misc


don't die or echo in classes, it makes code less flexible and harder to reuse, as the calling code cannot try to recover.
get_player and set_player could be renamed to get and set as the class is already called player.
It would probably also be good to rename set to save or similar, as it makes more explicit that there is some kind of database interaction (set sounds as if a private field is set).