... | @@ -31,5 +31,16 @@ spl_autoload_register(function ($class_name) { |
... | @@ -31,5 +31,16 @@ spl_autoload_register(function ($class_name) { |
|
```
|
|
```
|
|
Put this near the top of your script, not in the class itself.
|
|
Put this near the top of your script, not in the class itself.
|
|
|
|
|
|
|
|
## 2. database class
|
|
|
|
|
|
|
|
define a database class with the connection parameters (i.e. host, user, password, database name) are private attributes.
|
|
|
|
|
|
|
|
use __construct() to set the values for these so that a connection is made to your recordstore database.
|
|
|
|
|
|
|
|
define methods to open and close the database connection: something like ```public function openConnection()``` which assigns the mysqli connection to $this->connection.
|
|
|
|
|
|
|
|
define a method to execute an sql query: something like ```public function executeSql($sql)``` which returns the result of a mysqli_query
|
|
|
|
|
|
|
|
write a script to instantiate your class. open a database connection and execute a query to check it's all working properly.
|
|
|
|
|
|
|
|
|