Added highlighting for selected category
This commit is contained in:
@@ -46,15 +46,21 @@ class ProductController(DatabaseController):
|
||||
for product in rows:
|
||||
params = dict(zip(self.FIELDS, product))
|
||||
obj = self.new_instance(Product, params)
|
||||
print(obj.__dict__)
|
||||
products.push(obj)
|
||||
|
||||
return products
|
||||
|
||||
|
||||
def read_all(self) -> list[Product] | None:
|
||||
def read_all(self, category: str = "") -> list[Product] | None:
|
||||
params = [
|
||||
"%" + category + "%"
|
||||
]
|
||||
|
||||
cursor = self._conn.execute(
|
||||
"SELECT * FROM Products",
|
||||
"""SELECT * FROM Products
|
||||
INNER JOIN Categories ON Products.categoryID = Categories.id
|
||||
WHERE Categories.name LIKE ? """,
|
||||
params
|
||||
)
|
||||
rows = cursor.fetchall()
|
||||
|
||||
@@ -67,7 +73,6 @@ class ProductController(DatabaseController):
|
||||
for product in rows:
|
||||
params = dict(zip(self.FIELDS, product))
|
||||
obj = self.new_instance(Product, params)
|
||||
print(obj.__dict__)
|
||||
products.append(obj)
|
||||
|
||||
return products
|
||||
|
||||
Reference in New Issue
Block a user