Now, yesterday I talked about the basic PDO implementation of MySQL. Today I’m going to cover PHP’s new MySQL Improved Extension (MySQLi). It actually has two methods of approach: the Object-Oriented way and the Procedural way (why?). Here is a basic open and close connection:
Well, I’ve finished half the chapters. But those were the easy ones! Today’s chapter is Database Programming. Sadly most of the chapter is about SQL itself: data types, how to create tables, creating relationships/indexes, inserting/updating, transactions, etc. Fourteen pages later and we get to the actual PHP code.
Yesterday, we covered extending classes. Now in Object Oriented Programming, you can also create abstracted and interface classes. Abstracted classes are ones that cannot be used directly (they must be extended) and provide only a basic template of a class. Here is an example:
This it the real meat and potatoes of PHP. Classes contain methods (functions) and properties (variables). This basic concept is also known as encapsulation or information hiding.
Okay, let’s get though this before the new year! Finally this chapter will conclude with Header control, accessing cookies, and modifying sessions.