Exemple #1
0
    /**
     * Insert a row in the characters table
     *
     * @throws StatusCodeException 500 if was not inserted
     * 
     * @param DatabaseConnection database class instance
     * @param array $character character attributes without id 
     * @return string ID of character inserted
     */
    public static function insert(DatabaseConnection $db, $character)
    {
        $success = $db->query('INSERT INTO characters(name, description, type, dead, stage, hp) 
			VALUES(:name, :description, :type, :dead, :stage, :hp);', $character);
        $id = Self::lastID($db);
        if (!$success) {
            throw new StatusCodeException(500);
        }
        return $id;
    }