You are on page 1of 4

Advanced PHP Programming with MySQL

Table of Contents
Introduction............................................................................................ 6 Class Inheritance..............................................................................51
What this Course is About................................................................. 7 Autoloading Classes.........................................................................52
PHP Review............................................................................................9 Constructors and Destructors...........................................................54
PHP Basics.......................................................................................10 Member and Method Visibility........................................................56
Working with Arrays....................................................................... 15 The static Keyword.......................................................................... 57
Sorting Arrays............................................................................. 18 Abstract Classes............................................................................... 58
Variable Scope in PHP.....................................................................20 Object Interfaces.............................................................................. 59
Arithmetic Operators....................................................................... 22 Overloading......................................................................................60
Comparison Operators..................................................................... 24 Class Members.................................................................................61
The If and While Constructs............................................................ 27 Exercises.......................................................................................... 62
Exercises.......................................................................................... 28 Debugging PHP Code...........................................................................63
Functions..........................................................................................29 PHP Error Handling.........................................................................64
Declaring Functions.................................................................... 31 PHP Debugging Tools..................................................................... 65
Passing Data By Reference......................................................... 33 Creating Conditional Debug Code.............................................. 68
Including Code in Scripts.................................................................35 Suppressing Errors........................................................................... 69
Exercises..................................................................................... 36 Exercises.......................................................................................... 70
Executing OS Commands................................................................ 37 Managing Web Sessions.......................................................................71
Shell Execution Best Practices....................................................40 Using PHP Session Handling...........................................................72
Exercises.......................................................................................... 42 Managing Sessions Across Multiple Servers...................................74
Working with Web Forms............................................................... 43 PHP Cookie Handling......................................................................76
Exercises.......................................................................................... 46 Exercises.......................................................................................... 77
Perl Regular Expressions................................................................. 47 Handling Date & Time in PHP.............................................................79
Object Oriented Programming and PHP 5........................................... 49 Displaying Dates & Times...............................................................80
PHP 5 Objects.................................................................................. 50 Parsing a Date or Time.................................................................... 82

Page 2 of 310
Advanced PHP Programming with MySQL

Generating Relative Times.............................................................. 83 MySQL Server Security..................................................................... 140


Exercises.......................................................................................... 84 MySQL Security............................................................................ 141
Leveraging Existing Code The MySQL Privilege System....................................................... 144
using PEAR and PECL.........................................................................85 MySQL Default Users................................................................... 147
Introduction to PEAR...................................................................... 86 GRANT and REVOKE Statements............................................... 148
Exercises.......................................................................................... 91 Adding Users to MySQL............................................................... 154
Building Client-Server Applications.................................................... 92 Changing User Passwords..............................................................157
Client Server Programming Models................................................ 93 Client Access Control.................................................................... 158
Understanding XML-RPC............................................................... 97 Disabling Client Access Control............................................... 159
An XML-RPC Conversation.......................................................99 Exercises................................................................................... 160
Creating an XML-RPC Client....................................................... 101 Using MySQL Clients........................................................................ 161
Encapsulating Values with XML_RPC_Value()...................... 103 Client Overview............................................................................. 162
Retrieving Data from XML_RPC_Value() Objects..................105 Using Command-Line Clients....................................................... 164
Sending the Message & Receiving the Response.......................... 107 Specifying Connection Parameters........................................... 166
A Sample XML_RPC Client.....................................................109 Connection Examples................................................................171
Exercises........................................................................................ 110 Using Client Option files............................................................... 173
Creating an XML_RPC Server...................................................... 111 Using User Variables..................................................................... 174
A Sample XML_RPC Server.........................................................114 Exercises........................................................................................ 175
Exercises........................................................................................ 117 MySQL Stored Procedures................................................................. 176
Installing and Managing MySQL....................................................... 118 What are Stored Procedures?......................................................... 177
MySQL Installation for Windows................................................. 119 Stored Procedures & Functions..................................................... 179
The MySQL Server Instance Configuration Wizard................ 121 Creating Stored Procedures............................................................181
Starting and Stopping MySQL under Windows....................... 133 Creating Functions......................................................................... 183
MySQL Installation for Linux/Unix.............................................. 134 Stored Procedure & Function Characteristics................................185
Starting and Stopping the MySQL Server................................ 137 Execution Blocks in Stored Procedures & Functions.................... 187
Exercises........................................................................................ 139 The DECLARE Statement.............................................................188

Page 3 of 310
Advanced PHP Programming with MySQL

Working with Variables............................................................ 189 Exercises........................................................................................ 230


MySQL Error Codes................................................................. 190 Accessing Databases using PHP.........................................................232
Conditions and Handlers........................................................... 191 Using ADO DB..............................................................................233
Exit Handlers.............................................................................192 Why use ADODB?........................................................................ 234
Continue Handlers.....................................................................193 Installing ADODB......................................................................... 236
Undo Handlers.......................................................................... 194 Specifying Connection Properties..................................................237
The IF Statement............................................................................195 Constructing Queries..................................................................... 239
The CASE Statement..................................................................... 196 Executing Queries..........................................................................241
The LOOP, WHILE, and REPEAT Statements.............................197 Working with SELECT Results.....................................................244
Modifying Stored Procedures and Functions.................................201 Errors Returned from Queries........................................................248
Exercises................................................................................... 203 ADODB Performance Notes..........................................................249
Cursors in MySQL.........................................................................204 Debugging Queries........................................................................ 251
Exercises........................................................................................ 206 Single-Step Queries....................................................................... 253
Triggers in MySQL........................................................................207 Exercises................................................................................... 255
Creating MySQL Triggers............................................................. 209 PHP Best Practices............................................................................. 256
Exercises........................................................................................ 210 Exercises........................................................................................ 260
Using the MySQL Query Optimizer.................................................. 211 Appendix A – SQL Primer................................................................. 261
Index Types....................................................................................212 About the SELECT Statement....................................................... 262
The FULLTEXT Index............................................................. 216 Selecting Values to Display........................................................... 263
Index Usage................................................................................... 217 Restricting Selections Using the WHERE Clause......................... 267
Analyzing Queries......................................................................... 219 Using ORDER BY to Sort Query Results..................................... 270
Using EXPLAIN to Analyze Queries...................................... 221 Limiting a Selection Using LIMIT........................................... 273
Optimizing Queries........................................................................224 Computing Summary Values.........................................................275
Optimizing Updates....................................................................... 226 Using the GROUP BY Clause....................................................... 278
MySQL Prepared Statements.........................................................227 Using the HAVING Clause........................................................... 280
Using Summary Tables..................................................................229 Using DISTINCT to Eliminate Duplicates.................................... 281

Page 4 of 310
Advanced PHP Programming with MySQL

Using UNION to Join SELECT Results........................................282 Appendix C - Updating Tables Using SQL........................................296
Appendix B - SQL Expressions and Functions.................................. 284 The INSERT Statement................................................................. 297
What are Expressions and Functions?........................................... 285 The REPLACE Statement..............................................................299
Character Expressions and Functions............................................ 286 The UPDATE Statement................................................................302
Pattern Matching using LIKE........................................................ 288 The DELETE and TRUNCATE TABLE Statements....................303
Using IF() Statements.................................................................... 290 Appendix D - Joins............................................................................. 304
Using the IN() Function................................................................. 291 SELECT from Multiple Tables......................................................305
Comments in SQL Statements....................................................... 292 The Inner Join........................................................................... 306
Understanding NULL Values........................................................ 294 Outer Joins..................................................................................... 309

Page 5 of 310

You might also like