You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Build a lightweight base Model class using PDO to standardize database queries across all controllers. This avoids repeating boilerplate PDO code in every controller and makes the backend easier to maintain.
Tasks
Create models/Model.php — base class with:
Static db() method returning the PDO instance from config/database.php
findById($table, $id) helper
findAll($table, $conditions, $params) helper
insert($table, $data) — returns last insert ID
update($table, $data, $where, $params) helper
delete($table, $where, $params) helper
All queries use prepared statements
Create individual model classes that extend base:
models/User.php
models/Project.php
models/Application.php
models/Skill.php
models/Notification.php
models/Bookmark.php
Each model has domain-specific methods (e.g. Project::findBySlug(), User::findByEmail())
Create helpers/Validator.php with reusable validation helpers:
required($fields, $data)
email($value)
minLength($value, $min)
inArray($value, $allowed)
Acceptance Criteria
All models extend base Model
No raw SQL strings outside of model files
All queries use prepared statements (no string interpolation)
Validator helpers work correctly for common field types
Description
Build a lightweight base Model class using PDO to standardize database queries across all controllers. This avoids repeating boilerplate PDO code in every controller and makes the backend easier to maintain.
Tasks
models/Model.php— base class with:db()method returning the PDO instance fromconfig/database.phpfindById($table, $id)helperfindAll($table, $conditions, $params)helperinsert($table, $data)— returns last insert IDupdate($table, $data, $where, $params)helperdelete($table, $where, $params)helpermodels/User.phpmodels/Project.phpmodels/Application.phpmodels/Skill.phpmodels/Notification.phpmodels/Bookmark.phpProject::findBySlug(),User::findByEmail())helpers/Validator.phpwith reusable validation helpers:required($fields, $data)email($value)minLength($value, $min)inArray($value, $allowed)Acceptance Criteria