Join Jon Peck for an in-depth discussion in this video Retrieving objects from the database, part of Object-Oriented Programming with PHP.
I can also create a standard object straight from the database.…One of the methods in MySQLi, fetch_ object, returns the current row of a result…set as a standard class object.…Let's add this to the address model.…Let's go to the load function, which is currently a stub.…I am going to add a connection to the database. Connect to the database,…then write the query to retrieve a row from the address table by the primary key, address_id.…
For safety, I'm using quotations around the identifier, and casting the…identifier as an integer. sql_query equals SELECT everything from address, from…address where address_id equals (int) $address_id.…
The $result = mysqli ->query($sql_query).…Use the mysqli result object to fetch an object from the database.…If ($row = $result -> fetch_object. Display the row, then exit var_dump ($row) exit.…Save, then open the demo script.…
Remove the test object code, then add a title section for testing loading,…followed by a call to the static method load in the address class.…
- Historical overview of object-oriented PHP
- Defining classes
- Creating a method/object context with $this
- Accessing classes without instantiation
- Creating a database class
- Extending and abstracting classes
- Cloning and comparing objects
- Error handling with exceptions
- Implementing design patterns, such as the factory and strategy patterns
Skill Level Intermediate
PHP with MySQL Beyond the Basicswith Kevin Skoglund10h 26m Intermediate
1. Introduction to Object-Oriented Programming
2. Creating Your First Object
3. Overloading with Magic Methods
Overloading property access6m 37s
4. Accessing Classes without Instantiation
5. Class Relationships and Interactions
6. Built-In PHP Objects
Customizing PHP exceptions4m 23s
7. Design Patterns
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.