Let??™s move on!
CHAPTER 4 ?– CREATING THE PRODUCT CATALOG: PART 1 78
Communicating with the Database
Now that you have a table filled with data, let??™s do something useful with it! The ultimate goal
with this table is to get the list of department names from a PHP page and populate the
Smarty template with that list.
To get data from a database, you first need to know how to communicate with the database.
Relational databases understand dialects and variants of SQL. The usual way of communicating
with MySQL is to write an SQL command, send it to the MySQL server, and get the results back.
In practice, as you??™ll see later, we prefer to centralize the data access code using MySQL
stored procedures, but before you can learn about them, you need to know the basics of SQL.
The Structured Query Language (SQL)
SQL is the language used to communicate with modern relational database management
systems (RDBMSs). However, we haven??™t seen a database system yet that supports exactly the
SQL 99 and SQL 2003 standards. This means that in many cases, the SQL code that works with
one database will not work with the other. Currently, MySQL supports most of SQL 92 and an
important part of SQL 99.
The most commonly used SQL commands are SELECT, INSERT, UPDATE, and DELETE. These
commands allow you to perform the most basic operations on the database.
Pages:
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155