Also, when using PDO, you won??™t need to change the data access code if, for example, you
decide to use PostgreSQL instead of MySQL. On the other hand, the first code snippet, which
uses MySQL-specific functions, would need to change completely (use pg_connect and pg_query
instead of mysql_connect and mysql_query, and so on). In addition, some PostgreSQL-specific
functions have different parameters than the similar MySQL functions.
When using a database abstraction layer (such as PDO), you??™ll probably only need to change
the connection string when changing the database back end. Note that here we??™re only talking
CHAPTER 2 ?– LAYING OUT THE FOUNDATIONS 25
about the PHP code that interacts with the database. In practice, you might also need to update
some SQL queries if the database engines support different dialects of SQL.
?– Note To keep your SQL queries as portable as possible, keep their syntax as close as possible to the
SQL-92 standard. You??™ll learn more about SQL details in Chapter 4.
MySQL and the Three-Tier Architecture
It is clear by now that MySQL is somehow related to the data tier. However, if you haven??™t worked
with databases until now, it might be less than obvious that MySQL is more than a simple store
of data. Apart from the actual data stored inside, MySQL is also capable of storing logic in the
form of stored procedures, to maintain table relationships, to ensure various data integrity rules
are obeyed, and so on.
Pages:
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89