tailieunhanh - Beginning PHP and Postgre SQL 8 From Novice to Professional phần 9

Các kế hoạch PostgreSQL là một phần của PostgreSQL xác định làm thế nào để thực thi một truy vấn nhất định. Nó căn cứ quyết định của mình trên các số liệu thống kê thu thập được thông qua lệnh phân tích và một số ít các tùy chọn trong file . | 688 CHAPTER 30 PHP S POSTGRESQL FUNCTIONALITY This is just a sample of what s possible using the information schema. You can also use it to learn more about all databases residing on the cluster users user privileges views and much more. See the PostgreSQL documentation for a complete breakdown of what s available within this schema. Applying this to PHP you can execute the appropriate query and parse the results using your pg_fetch_ function of choice. For example php . tablename product query SELECT column_name data_type FROM WHERE table_name tablename result pg_query query echo b tablename b table structure br while row pg_fetch_row result column row 0 datatype row 1 echo column datatype br This returns the following product table structure productid integer productcode character description character varying name character varying price numeric Summary This chapter introduced PHP s PostgreSQL extension offering numerous examples demonstrating its capabilities. You ll definitely become quite familiar with many of its functions as your experience building PHP and PostgreSQL-driven applications progresses. The next chapter shows you how to more efficiently manage PostgreSQL queries using a custom database class. CHAPTER 31 Practical Database Queries The previous chapter introduced PHP s PostgreSQL extension and demonstrated basic queries involving data selection. This chapter expands upon this foundational knowledge demonstrating numerous concepts that you re bound to return to repeatedly while creating database-driven Web applications using the PHP language. In particular you ll learn how to implement the following concepts A PostgreSQL database class Managing your database queries using a class not only results in cleaner application code but also enables you to quickly and easily extend and modify query capabilities as necessary. This chapter presents a PostgreSQL database class implementation and provides several introductory .