did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9781590595473

Beginning PHP and PostgreSQL 8

by
  • ISBN13:

    9781590595473

  • ISBN10:

    1590595475

  • Format: Paperback
  • Copyright: 2006-02-27
  • Publisher: Apress
  • Purchase Benefits
  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $59.99 Save up to $43.11
  • Buy New
    $58.19
    Add to Cart Free Shipping Icon Free Shipping

    USUALLY SHIPS IN 2-3 BUSINESS DAYS

Supplemental Materials

What is included with this book?

Summary

Beginning PHP 5 and PostgreSQL 8 delves into some of the most popular open source web development technologies, the PostgreSQL 8 database server and PHP 5 scripting language. You'll learn to reap the benefits of these core technologies by using them in unison to create dynamic, data-driven web applications. This is an ideal read if you are a web designer, programmer, hobbyist, or novice who wants to create applications with PHP 5 and PostgreSQL 8.

Table of Contents

About the Authors xxv
About the Technical Reviewers xxvii
Acknowledgments xxix
Introduction xxxi
An Introduction to PHP
1(8)
History
1(3)
PHP 4
2(1)
PHP 5
3(1)
General Language Features
4(3)
Practicality
5(1)
Power
5(1)
Possibility
6(1)
Price
7(1)
Summary
7(2)
Installing and Configuring Apache and PHP
9(34)
Installation
9(10)
Obtaining the Distributions
9(2)
The Installation Process
11(5)
Testing Your Installation
16(1)
Customizing the Unix Build
17(1)
Customizing the Windows Build
17(1)
Common Pitfalls
18(1)
Viewing and Downloading the Documentation
18(1)
Configuration
19(22)
Managing PHP's Configuration Directives
19(2)
PHP's Configuration Directives
21(20)
Summary
41(2)
PHP Basics
43(48)
Escaping to PHP
43(3)
Default Syntax
44(1)
Short-Tags
44(1)
Script
45(1)
ASP-Style
45(1)
Embedding Multiple Code Blocks
45(1)
Comments
46(1)
Single-line C++ Syntax
46(1)
Shell Syntax
46(1)
Multiple-Line C Syntax
46(1)
Output
47(3)
Print()
47(1)
echo()
48(1)
printf()
49(1)
sprintf()
50(1)
Datatypes
50(7)
Scalar Datatypes
50(2)
Compound Datatypes
52(1)
Special Datatypes
53(1)
Type Casting
54(1)
Type Juggling
55(1)
Type-Related Functions
56(1)
Type Identifier Functions
57(1)
Identifiers
57(1)
Variables
58(10)
Variable Declaration
58(2)
Variable Scope
60(3)
PHP's Superglobal Variables
63(4)
Variable Variables
67(1)
Constants
68(1)
Expressions
68(7)
Operands
69(1)
Operators
69(6)
String Interpolation
75(3)
Double Quotes
75(1)
Single Quotes
76(1)
Heredoc
77(1)
Control Structures
78(11)
Execution Control Statements
78(1)
Conditional Statements
79(2)
Looping Statements
81(5)
File Inclusion Statements
86(3)
Summary
89(2)
Functions
91(12)
Invoking a Function
91(1)
Creating a Function
92(8)
Passing Arguments by Value
92(1)
Passing Arguments by Reference
93(1)
Default Argument Values
94(1)
Optional Arguments
94(1)
Returning Values from a Function
95(1)
Nesting Functions
96(1)
Recursive Functions
97(2)
Variable Functions
99(1)
Function Libraries
100(1)
Summary
101(2)
Arrays
103(30)
What Is an Array?
104(1)
Outputting Arrays
105(1)
Creating an Array
106(2)
Testing for an Array
108(1)
Adding and Removing Array Elements
109(2)
Locating Array Elements
111(1)
Traversing Arrays
112(4)
Determining Array Size and Uniqueness
116(2)
Sorting Arrays
118(6)
Merging, Slicing, Splicing, and Dissecting Arrays
124(5)
Other Useful Array Functions
129(2)
Summary
131(2)
Object-Oriented PHP
133(24)
The Benefits of OOP
134(1)
Encapsulation
134(1)
Inheritance
134(1)
Polymorphism
135(1)
Key OOP Concepts
135(12)
Classes
135(1)
Objects
136(1)
Fields
137(3)
Properties
140(1)
__set()
140(3)
Constants
143(1)
Methods
143(4)
Type Hinting
147(1)
Constructors and Destructors
148(4)
Constructors
148(3)
Destructors
151(1)
Static Class Members
152(1)
The Instance of Keyword
153(1)
Helper Functions
153(2)
Autoloading Objects
155(1)
Summary
156(1)
Advanced OOP Features
157(20)
Advanced OOP Features Not Supported by PHP
157(1)
Object Cloning
158(3)
Cloning Example
158(2)
The_clone() Method
160(1)
Inheritance
161(4)
Class Inheritance
162(2)
Inheritance and Constructors
164(1)
Interfaces
165(3)
Implementing a Single Interface
167(1)
Implementing Multiple Interfaces
168(1)
Abstract Classes
168(1)
Reflection
169(7)
Writing the ReflectionClass Class
170(2)
Writing the ReflectionMethod Class
172(2)
Writing the ReflectionParameter Class
174(1)
Writing the ReflectionProperty Class
175(1)
Other Reflection Applications
176(1)
Summary
176(1)
Error and Exception Handling
177(14)
Configuration Directives
177(3)
Error Logging
180(3)
Exception Handling
183(6)
Why Exception Handling Is Handy
183(2)
PHP's Exception-Handling Implementation
185(4)
Summary
189(2)
Strings and Regular Expressions
191(38)
Complex (Curly) Offset Syntax
191(1)
Regular Expressions
192(13)
Regular Expression Syntax (POSIX)
193(2)
PHP's Regular Expression Functions (POSIX Extended)
195(3)
Regular Expression Syntax (Perl Style)
198(7)
Other String-Specific Functions
205(21)
Determining the Length of a String
205(1)
Comparing Two Strings
206(2)
Manipulating String Case
208(1)
Converting Strings to and from HTML
209(5)
Alternatives for Regular Expression Functions
214(8)
Padding and Stripping a String
222(2)
Counting Characters and Words
224(2)
Taking Advantage of PEAR: Validate_US
226(1)
Installing Validate_US
226(1)
Using Validate_US
227(1)
Summary
227(2)
Working with the File and Operating System
229(30)
Learning About Files and Directories
230(9)
Parsing Directory Paths
230(2)
File Types and Links
232(3)
Calculating File, Directory, and Disk Sizes
235(3)
Access and Modification Times
238(1)
File Ownership and Permissions
239(3)
File I/O
242(10)
The Concept of a Resource
242(1)
Newline
242(1)
End-of-File
242(1)
Opening and Closing a File
242(2)
Reading from a File
244(5)
Moving the File Pointer
249(1)
Writing to a File
250(1)
Reading Directory Contents
251(1)
Executing Shell Commands
252(2)
PHP's Built-in System Commands
252(2)
System-Level Program Execution
254(4)
Sanitizing the Input
254(1)
PHP's Program Execution Functions
255(3)
Summary
258(1)
Pear
259(12)
Popular PEAR Packages
259(3)
Converting Numeral Formats
261(1)
Installing and Updating PEAR
262(2)
Installing PEAR
262(1)
PEAR and Hosting Companies
263(1)
Updating PEAR
264(1)
Using the PEAR Package Manager
264(6)
Viewing Installed Packages
264(1)
Learning More About an Installed Package
265(1)
Installing a Package
266(1)
Using a Package
267(1)
Upgrading a Package
268(1)
Uninstalling a Package
269(1)
Downgrading a Package
269(1)
Summary
270(1)
Date and Time
271(32)
The Unix Timestamp
271(1)
PHP's Date and Time Library
272(7)
Date Fu
279(9)
Displaying the Localized Date and Time
279(4)
Displaying the Web Page's Most Recent Modification Date
283(1)
Determining the Number Days in the Current Month
283(1)
Calculating the Date X Days from the Present Date
284(1)
Creating a Calendar
285(3)
PHP 5.1
288(13)
Date Fundamentals
289(1)
The Date Constructor
289(1)
Accessors and Mutators
290(3)
Validators
293(1)
Manipulation Methods
294(7)
Summary
301(2)
Forms and Navigational Cues
303(22)
PHP and Web Forms
303(10)
A Simple Example
304(2)
Passing Form Data to a Function
306(1)
Working with Multivalued Form Components
307(1)
Generating Forms with PHP
308(2)
Autoselecting Forms Data
310(1)
PHP, Web Forms, and JavaScript
311(2)
Navigational Cues
313(10)
User-Friendly URLs
313(4)
Breadcrumb Trails
317(4)
Creating Custom Error Handlers
321(2)
Summary
323(2)
Authentication
325(20)
HTTP Authentication Concepts
325(1)
PHP Authentication
326(11)
Authentication Variables
327(1)
Authentication Methodologies
328(9)
User Login Administration
337(7)
Password Designation
337(2)
Testing Password Guessability with the CrackLib Library
339(3)
One-Time URLs and Password Recovery
342(2)
Summary
344(1)
Handling File Uploads
345(14)
Uploading Files via the HTTP Protocol
345(1)
Handling Uploads with PHP
346(9)
PHP's File Upload/Resource Directives
346(2)
The $_ Files Array
348(1)
PHP's File-Upload Functions
349(1)
Upload Error Messages
350(1)
File-Upload Examples
351(4)
Taking Advantage of PEAR: HTTP_Upload
355(3)
Installing HTTP_Upload
355(1)
Learning More About an Uploaded File
355(1)
Moving an Uploaded File to the Final Destination
356(1)
Uploading Multiple Files
357(1)
Summary
358(1)
Networking
359(40)
DNS, Services, and Servers
360(7)
DNS
360(4)
Services
364(1)
Establishing Socket Connections
365(2)
Mail
367(5)
Configuration Directives
367(2)
Sending a Plain-Text E-Mail
369(1)
Sending an E-Mail with Additional Headers
369(1)
Sending an E-Mail to Multiple Recipients
369(1)
Sending an HTML-Formatted E-Mail
370(1)
Sending an Attachment
371(1)
IMAP, POP3, and NNTP
372(18)
Requirements
373(1)
Establishing and Closing a Connection
374(1)
Learning More About Mailboxes and Mail
375(3)
Retrieving Messages
378(8)
Composing a Message
386(1)
Sending a Message
387(1)
Mailbox Administration
388(1)
Message Administration
389(1)
Streams
390(3)
Stream Wrappers and Contexts
390(1)
Stream Filters
391(2)
Common Networking Tasks
393(5)
Pinging a Server
394(1)
A Port Scanner
395(1)
Subnet Converter
395(2)
Testing User Bandwidth
397(1)
Summary
398(1)
PHP and LDAP
399(26)
An Introduction to LDAP
400(1)
Learning More About LDAP
400(1)
Using LDAP from PHP
401(22)
Connecting to the LDAP Server
401(1)
Binding to the LDAP Server
402(1)
Closing the LDAP Server Connection
403(1)
Retrieving LDAP Data
404(1)
Working with Entry Values
405(2)
Counting Retrieved Entries
407(1)
Retrieving Attributes
407(3)
Sorting and Comparing LDAP Entries
410(2)
Working with Entries
412(3)
Deallocating Memory
415(1)
Inserting LDAP Data
415(2)
Updating LDAP Data
417(1)
Deleting LDAP Data
417(1)
Configuration Functions
418(2)
Character Encoding
420(1)
Working with the Distinguished Name
421(1)
Error Handling
422(1)
Summary
423(2)
Session Handlers
425(22)
What Is Session Handling?
425(2)
Cookies
426(1)
URL Rewriting
426(1)
The Session-Handling Process
426(1)
Configuration Directives
427(5)
Key Concepts
432(5)
Starting a Session
432(1)
Destroying a Session
433(1)
Retrieving and Setting the Session ID
434(1)
Creating and Deleting Session Variables
434(1)
Encoding and Decoding Session Data
435(2)
Practical Session-Handling Examples
437(4)
Auto-Login
437(2)
Recently Viewed Document Index
439(2)
Creating Custom Session Handlers
441(5)
Tying Custom Session Functions into PHP's Logic
441(1)
Custom PostgreSQL-Based Session Handlers
442(4)
Summary
446(1)
Templating with Smarty
447(26)
What's a Templating Engine?
447(2)
Introducing Smarty
449(1)
Installing Smarty
450(2)
Using Smarty
452(2)
Smarty's Presentational Logic
454(11)
Comments
454(1)
Variable Modifiers
454(3)
Control Structures
457(5)
Statements
462(3)
Creating Configuration Files
465(2)
config_load
465(1)
Referencing Configuration Variables
466(1)
Using CSS in Conjunction with Smarty
467(1)
Caching
468(3)
Working with the Cache Lifetime
468(1)
Eliminating Processing Overhead with is_cached()
469(1)
Creating Multiple Caches per Template
470(1)
Some Final Words About Caching
471(1)
Summary
471(2)
Web Services
473(42)
Why Web Services?
474(2)
Real Simple Syndication
476(10)
RSS Syntax
478(1)
MagpieRSS
479(7)
SimpleXML
486(5)
SimpleXML Functions
486(2)
SimpleXML Methods
488(3)
SOAP
491(21)
NuSOAP
492(10)
PHP 5's SOAP Extension
502(10)
Using a C# Client with a PHP Web Service
512(2)
Summary
514(1)
Secure PHP Programming
515(20)
Configuring PHP Securely
516(4)
Safe Mode
516(2)
Other Security-Related Configuration Parameters
518(2)
Hiding Configuration Details
520(2)
Hiding Apache and PHP
520(2)
Hiding Sensitive Data
522(2)
Take Heed of the Document Root
523(1)
Denying Access to Certain File Extensions
523(1)
Sanitizing User Data
524(4)
File Deletion
524(1)
Cross-Site Scripting
524(2)
Sanitizing User Input: The Solution
526(2)
Data Encryption
528(4)
PHP's Encryption Functions
528(1)
mhash
529(2)
MCrypt
531(1)
Summary
532(3)
SQLite
535(20)
Introduction to SQLite
535(2)
Installing SQLite
536(1)
Using the SQLite Command-Line Interface
536(1)
PHP's SQLite Library
537(16)
SQLite Directives
537(1)
Opening a Connection
538(1)
Creating a Table in Memory
539(1)
Closing a Connection
539(1)
Querying a Database
540(1)
Parsing Result Sets
541(3)
Retrieving Result Set Details
544(2)
Manipulating the Result Set Pointer
546(2)
Learning More About Table Schemas
548(1)
Working with Binary Data
549(1)
Creating and Overriding SQLite Functions
550(1)
Creating Aggregate Functions
551(2)
Summary
553(2)
Introducing PDO
555(18)
Another Database Abstraction Layer?
556(1)
Using PDO
557(15)
Installing PDO
558(1)
PDO's Database Support
558(1)
Connecting to a Database Server and Selecting a Database
559(2)
Getting and Setting Attributes
561(1)
Error Handling
561(1)
Query Execution
562(2)
Prepared Statements
564(3)
Retrieving Data
567(3)
Setting Bound Columns
570(1)
Transactions
571(1)
Summary
572(1)
Introducing PostgreSQL
573(6)
PostgreSQL's Key Features
574(2)
Data Integrity
574(1)
Highly Scalable
574(1)
Feature-Complete
574(1)
Extensible
574(1)
Platform Support
574(1)
Flexible Security Options
575(1)
Global Development, Local Flavor
575(1)
Hassle-Free Licensing
575(1)
Multiple Support Avenues
576(1)
Real-World Users
576(1)
Afilias Inc
576(1)
The National Weather Service
577(1)
WhitePages.com
577(1)
Summary
577(2)
Installing PostgreSQL
579(14)
PostgreSQL Licensing Requirements
579(1)
Downloading PostgreSQL
579(2)
Downloading the Unix Version
580(1)
Downloading the Windows Version
580(1)
Downloading the Documentation
581(1)
Installing PostgreSQL
581(8)
Installing PostgreSQL on Linux and Unix
582(3)
Installing PostgreSQL on Windows 2000, XP, and 2003
585(4)
Installing PostgreSQL on Windows 95, 98, and ME
589(1)
Starting PostgreSQL for the First Time
589(2)
Summary
591(2)
PostgreSQL Administration
593(18)
Starting and Stopping the Server
593(3)
Tuning Your PostgreSQL Installation
596(5)
Working with Tablespaces
601(1)
Vacuum and Analyze
602(2)
Autovacuum
604(1)
Backup and Recovery
605(4)
Upgrading Between Versions
609(1)
Summary
610(1)
The Many PostgreSQL Clients
611(14)
What Is psql?
611(2)
psql Options
612(1)
Commonplace psql Tasks
613(7)
Logging Onto and Off the Server
613(1)
psql Commands
613(2)
Storing psql Variables and Options
615(2)
Learning More About Supported SQL Commands
617(1)
Executing a Query
618(1)
Modifying the psql Prompt
618(1)
Controlling the Command History
619(1)
GUI-based Clients
620(3)
pgAdmin III
620(1)
phpPgAdmin
621(1)
Navicat
622(1)
Summary
623(2)
From Databases to Datatypes
625(24)
Working with Databases
625(2)
Default Databases
625(1)
Creating a Database
626(1)
Connecting to a Database
626(1)
Deleting a Database
626(1)
Modifying Existing Databases
627(1)
Working with Schemas
627(2)
Creating Schemas
627(1)
Altering Schemas
628(1)
Dropping Schemas
628(1)
The Schema Search Path
628(1)
Working with Tables
629(3)
Creating a Table
629(1)
Copying a Table
630(1)
Creating a Temporary Table
630(1)
Viewing a Database's Available Tables
631(1)
Viewing Table Structure
631(1)
Deleting a Table
632(1)
Altering a Table Structure
632(1)
Working with Sequences
633(2)
Creating a Sequence
633(1)
Modifying Sequences
633(1)
Sequence Functions
634(1)
Deleting a Sequence
635(1)
Datatypes and Attributes
635(9)
Datatypes
635(5)
Datatype Attributes
640(4)
Composite Datatypes
644(1)
Creating Composite Types
644(1)
Altering Composite Types
645(1)
Dropping Composite Types
645(1)
Working with Domains
645(2)
Creating Domains
646(1)
Altering Domains
646(1)
Dropping Domains
647(1)
Summary
647(2)
Securing PostgreSQL
649(16)
What You Should Do First
649(2)
Securing the PostgreSQL Daemon
651(1)
The PostgreSQL Access Privilege System
651(14)
How the Privilege System Works
652(1)
Where Is Access Information Stored?
652(5)
User and Privilege Management
657(4)
Secure PostgreSQL Connections
661(2)
Summary
663(2)
PHP's PostgreSQL Functionality
665(24)
Prerequisites
665(2)
Enabling PHP's PostgreSQL Extension
665(1)
PHP's PostgreSQL Configuration Directives
666(1)
Sample Data
667(1)
PHP's PostgreSQL Commands
667(4)
Establishing and Closing a Connection
667(4)
Queries
671(2)
Query Execution
671(2)
Retrieving Status and Error Information
673(9)
Recuperating Query Memory
678(1)
Retrieving and Displaying Data
678(3)
Rows Selected and Rows Affected
681(1)
Inserting, Modifying, and Deleting Data
682(3)
Inserting Data
682(1)
Mass Inserts
683(1)
Modifying Data
684(1)
Deleting Data
685(1)
Prepared Statements
685(2)
The Information Schema
687(1)
Summary
688(1)
Practical Database Queries
689(18)
Sample Data
689(1)
Creating a PostgreSQL Database Class
690(16)
Why Use the PostgreSQL Database Class?
692(1)
Executing a Simple Query
693(1)
Retrieving Multiple Rows
694(1)
Counting Queries
694(1)
Tabular Output
695(2)
Linking to a Detailed View
697(2)
Sorting Output
699(2)
Creating Paged Output
701(3)
Listing Page Numbers
704(2)
Summary
706(1)
Views and Rules
707(12)
Working with Views
707(1)
The PostgreSQL Rule System
708(3)
Working with Rules
708(2)
Rule Types
710(1)
Making Views Interactive
711(5)
Working with Views from Within PHP
716(1)
Summary
717(2)
PostgreSQL Functions
719(20)
Operators
719(4)
Logical Operators
719(1)
Comparison Operators
720(1)
Mathematical Operators
721(1)
String Operators
721(1)
Operator Precedence
722(1)
Internal Functions
723(4)
Date and Time Functions
723(1)
String Functions
724(1)
Aggregate Functions
724(1)
Conditional Expressions
725(2)
More Functions
727(1)
User-Defined Functions
727(11)
Create Function Syntax
727(1)
SQL-Based Functions
728(2)
PL/pgSQL-Based Functions
730(6)
Other Procedural Languages
736(2)
Summary
738(1)
PostgreSQL Triggers
739(10)
What Is a Trigger?
739(2)
Adding Triggers
739(1)
Modifying Triggers
740(1)
Removing Triggers
741(1)
Writing Trigger Functions
741(6)
Example Trigger Functions
742(4)
Viewing Existing Triggers
746(1)
Summary
747(2)
Indexes and Searching
749(16)
Database Indexing
749(10)
Primary Key Indexes
750(1)
Unique Indexes
750(1)
Normal Indexes
751(4)
Full-Text Indexes
755(4)
Indexing Best Practices
759(1)
Forms-Based Searches
759(5)
Performing a Simple Search
760(1)
Extending Search Capabilities
761(2)
Performing a Full-Text Search
763(1)
Summary
764(1)
Transactions
765(12)
What's a Transaction?
765(1)
PostgreSQL's Transactional Capabilities
766(5)
Transaction Isolation
766(1)
Sample Project
767(1)
A Simple Example
768(3)
Transaction Usage Tips
771(1)
Building Transactional Applications with PHP
771(4)
Beware of pg_query()
772(1)
The Swap Meet Revisited
773(2)
Summary
775(2)
Importing and Exporting Data
777(10)
The COPY Command
777(6)
Copying Data to and from a Table
778(4)
Calling COPY from a PHP Script
782(1)
Importing and Exporting Data with phpPgAdmin
783(2)
Summary
785(2)
Index 787

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Rewards Program