TAILIEUCHUNG - OBJECT-ORIENTED PHP Concepts, Techniques, and Code- P19

OBJECT-ORIENTED PHP Concepts, Techniques, and Code- P19:A number of years ago, before I started using PHP, I created dynamic web pages using C. This really wasn’t too different from some of the other options available at the time, though it seems almost unthinkable now. Creating a dynamic page meant outputting HTML from your script and recompiling that script if any changes needed to be made. | unbuffered behavior is easily reproduced. Our SQLite application uses buffered result sets in cases where we need to know that there are records returned or where the specific number of records is required. To buffer records using PDO you can use the fetchAll method of a statement to return an array. A record count can be obtained by using the count function on the returned array. Alternately calling the function empty on the statement returned by a query will determine whether there is at least one record. In general when querying the database it looks like some efficiencies have been lost. What is a single process using SQLite becomes a two-step process with PDO. Using two methods instead of one can make code more complicated. However as we ll soon see there are some important advantages to the PDO methods and in some cases this two-step process can be simplified. Additional Capabilities of PDO Converting one application certainly doesn t tell the whole story about PDO so let s have a look at some of the other capabilities of PDO. There are three PDO classes PDO the database or connection class PDOStatement and PDORow. By far the most interesting and unfamiliar class is the statement class and this is where we ll concentrate our attention. We ll briefly discuss PDORow when we come to the fetchObject method of the statement class. The PDO Class So far in this book we ve created our own connection class and used the SQLiteDatabase class classes that have many similarities to PDO. With this experience I needn t say a lot about the PDO class. I ve already mentioned the quote setAttribute and query methods of the PDO class. For databases such as SQLite that support transactions this class also has methods to begin commit or roll back transactions. The most important method however is prepare. This method is similar to the query method in that it also returns a PDOStatement. The major difference is that query is typically used for SQL statements that are issued once .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.