PHP 5/MySQL Programming- P68

PHP 5/MySQL Programming- P68:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | 313 figure The result of the SELECT statement is a table just like the original plan. Writing a Script to Build a Table It is very important to understand how to create tables by hand in SQL because your programs have to do this same work. However it s very tedious to write your SQL code in the MySQL window directly. When you create real data applications you often have to build and rebuild your data tables several times before you are satisfied with them and this would be awkward in the command-line interface. Also as you are writing programs that work with your database you will likely make mistakes that corrupt the original data. It s good to have a script ready for easily rebuilding the database with test data. Most programmers create a script of SQL commands with a text editor use the same editor in which you write your PHP code and use the SOURCE command to load that code. Here is an SQL script for creating the phoneList database build phone list for mySQL USE chapter9 DROP TABLE IF EXISTS phoneList Chapter 9 Using MySQL to Create Databases CREATE TABLE phoneList id INT PRIMARY KEY firstName VARCHAR 15 lastName VARCHAR 15 314 PHP 5 MySQL Programming for the Absolute Beginner email VARCHAR 20 phone VARCHAR 15 INSERT INTO phoneList VALUES 0 Andy Harris aharris@ 123-4567 SELECT FROM phoneList This code isn t exactly like what I used in the interactive session because the new code shows a few more features that are especially handy when you create SQL code in a script. Creating Comments in SQL SQL is actually a language. Although it isn t technically a programming language it has many of the same features. Like PHP and other languages SQL supports several types of comment characters. The sign is often used to signify a comment in SQL. Comments are especially important when you save a group of SQL commands in a file for later reuse. These comments can help you remember what type of database you were trying to build. It s critical to put basic .

Không thể tạo bản xem trước, hãy bấm tải xuống
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.