def get_all(cls): query = "SELECT * FROM users;" results = connectToMySQL('users_schema').query_db(query) users = [] for i in results: users.append(cls(i)) return users
def destroy(cls, data): query = "DELETE FROM `users_schema`.`users` WHERE id = %(id)s;" return connectToMySQL('users_schema').query_db(query, data)
def update(cls, data): query = "UPDATE users SET `first_name`= %(first_name)s, `last_name` = %(last_name)s, `email` = %(email)s, `updated_at` = NOW() WHERE id = %(id)s;" return connectToMySQL('users_schema').query_db(query, data)
def get_by_id(cls, data): query = "SELECT * FROM users WHERE id = %(id)s;" results = connectToMySQL('users_schema').query_db(query, data) return cls(results[0])
def save(cls, data): query = "INSERT INTO users (`first_name`, `last_name`, `email`, `created_at`, `updated_at`) VALUES (%(first_name)s, %(last_name)s, %(email)s, NOW(), NOW())" return connectToMySQL('users_schema').query_db(query, data)