This video will be available to
subscribers on Tue, May 20, 2025.
subscribers on Tue, May 20, 2025.
You must be a subscriber to view this video.
May 20, 2025
20m:53s
Database Infrastructure
Classification
Software Engineering | Languages | PHP
Keywords
oop | php
About This Episode:
Let’s encapsulate our database logic the pragmatic way! In this video, we refactor our raw database code into a dedicated Database class, making connections and queries more reusable, readable, and testable. 🛠️
Here’s what we’ll do:
Create a Framework/Database class that accepts config parameters in the constructor ⚙️
Expose an exec() method for executing raw SQL 🧾
Add a static instance for quick access to a shared connection 🌐
Introduce helper methods: first() to fetch a single record & all() to fetch multiple records
Write a simple query to fetch a photo by ID and pass it into the view dynamically 📸
Update the View class to properly render passed variables inside templates
Introduce a private render_template() method to handle this cleanly 🧩
By the end of this refactor, we’ll be on version v12-db-encapsulation—with database access that’s clean, powerful, and built to scale. 🚀
Here’s what we’ll do:
Create a Framework/Database class that accepts config parameters in the constructor ⚙️
Expose an exec() method for executing raw SQL 🧾
Add a static instance for quick access to a shared connection 🌐
Introduce helper methods: first() to fetch a single record & all() to fetch multiple records
Write a simple query to fetch a photo by ID and pass it into the view dynamically 📸
Update the View class to properly render passed variables inside templates
Introduce a private render_template() method to handle this cleanly 🧩
By the end of this refactor, we’ll be on version v12-db-encapsulation—with database access that’s clean, powerful, and built to scale. 🚀
Short Bio:
Bob Cravens is a seasoned technology leader, software architect, and educator with a passion for empowering others through practical, real-world knowledge. As the founder of TekFoundry, Bob has dedicated his career to designing and delivering innovative software solutions that combine cutting-edge technology with elegant simplicity.
At TekCasts, Bob leverages over two decades of experience in software engineering, application architecture, and team leadership to create engaging, high-impact courses for developers and technology professionals. His instructional style is rooted in practical application, offering insights drawn from his extensive background in industries like medical devices and global technology consulting.
Bob’s expertise spans a variety of technologies and methodologies, including PHP/Laravel, FastAPI, and DevOps, as well as architecture best practices and team dynamics. Whether teaching foundational concepts or advanced strategies, he’s passionate about helping others turn complex challenges into streamlined solutions.
When not crafting elegant code or inspiring the next generation of tech innovators, Bob enjoys exploring the intersection of technology, business strategy, and creative problem-solving.
At TekCasts, Bob leverages over two decades of experience in software engineering, application architecture, and team leadership to create engaging, high-impact courses for developers and technology professionals. His instructional style is rooted in practical application, offering insights drawn from his extensive background in industries like medical devices and global technology consulting.
Bob’s expertise spans a variety of technologies and methodologies, including PHP/Laravel, FastAPI, and DevOps, as well as architecture best practices and team dynamics. Whether teaching foundational concepts or advanced strategies, he’s passionate about helping others turn complex challenges into streamlined solutions.
When not crafting elegant code or inspiring the next generation of tech innovators, Bob enjoys exploring the intersection of technology, business strategy, and creative problem-solving.