Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Sichere ProgrammierungRecovering API Usage Automatically in Static Analysis?(20.09.2026 um 04:32 Uhr)
•
Sicherheitslücken (CVE)just dropped macos lpe - CVE-2026-43786(21.09.2026 um 21:48 Uhr)
••
Malware / Trojaner / VirenCDC-ACM Serial Interface Bypasses TCC on macOS(25.09.2026 um 19:18 Uhr)
•
Malware / Trojaner / VirenHow to start?(26.09.2026 um 00:24 Uhr)
•
Malware / Trojaner / VirenNeed an honest advice from seniors(26.09.2026 um 04:36 Uhr)
•
Malware / Trojaner / VirenFree malware analysis, reverse engineering and exploit development resources(27.09.2026 um 18:01 Uhr)
•••
Malware / Trojaner / VirenWhere to get resources and get started with malware dev?(30.09.2026 um 08:17 Uhr)
•
Sichere ProgrammierungRecovering API Usage Automatically in Static Analysis?(20.09.2026 um 04:32 Uhr)
•
Sicherheitslücken (CVE)just dropped macos lpe - CVE-2026-43786(21.09.2026 um 21:48 Uhr)
••
Malware / Trojaner / VirenCDC-ACM Serial Interface Bypasses TCC on macOS(25.09.2026 um 19:18 Uhr)
•
Malware / Trojaner / VirenHow to start?(26.09.2026 um 00:24 Uhr)
•
Malware / Trojaner / VirenNeed an honest advice from seniors(26.09.2026 um 04:36 Uhr)
•
Malware / Trojaner / VirenFree malware analysis, reverse engineering and exploit development resources(27.09.2026 um 18:01 Uhr)
•••
Malware / Trojaner / VirenWhere to get resources and get started with malware dev?(30.09.2026 um 08:17 Uhr)
•
Intelligence View
⚡ tsecurity.de Intelligence

Build a PHP QueryBuilder from scratch!

I recently completed one of the most challenging milestones of my framework: the ORM and QueryBuilder system. It’s a complex component that required deep u…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!

I recently completed one of the most challenging milestones of my framework: the ORM and QueryBuilder system.


It’s a complex component that required deep understanding of OOP, SQL abstraction, and design principles.





The Goal



I wanted to understand what truly happens behind the scenes when writing fluent database queries.


Instead of using Laravel or Symfony, I decided to build my own ORM from scratch — focusing on architecture, not shortcuts.









Architecture Overview




The Soft ORM system is inspired by modern framework technologies,


but built entirely from scratch.


Every Model represents a table, and the QueryBuilder dynamically generates and executes SQL statements.




Execution Flow





  1. User::find(1) → Extends the base Model


  2. Model.php → Creates the instance and forwards static calls to the QueryBuilder


  3. QueryBuilder.php → Builds the SQL query (SELECT * FROM ...)


  4. Database.php → Singleton PDO that executes the query


  5. ResultSet → Handles model hydration









Design Patterns
































Pattern Purpose
Active Record Each Model manages its table and CRUD operations.
Builder The QueryBuilder constructs SQL queries fluently.
Dependency Injection PDO is injected via container for separation of concerns.
Chain of Responsibility Methods like where() and join() return self for chaining.
Fail Fast Design Invalid Model structures throw ModelStructureException.


Writing an ORM from scratch forces a focus on architecture, abstraction, and class responsibility.


It reveals the value of separation between logic, data, and infrastructure layers.



The first unit tests for the QueryBuilder validate SQL generation and parameter binding.


They ensure the ORM behaves consistently before adding advanced features such as relationships and eager loading.



Try It Out



Repository:


GitHub – dev-iadicola/soft-php-mvc







bash
git clone https://github.com/dev-iadicola/soft-php-mvc.git
cd soft-php-mvc
composer install
php soft serve


Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Build a PHP QueryBuilder from scratch!

Thematisch verwandte Begriffe: Build, QueryBuilder, from, scratch · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag