-
- Weitere Informationen zu diesem Buch:
Inhaltsverzeichnis | Index | Probekapitel | Kolophon | Rezensionen |
- Weitere Informationen zu diesem Buch:
Second Edition Mai 2004
ISBN 978-0-596-00543-6
Weitere Informationen zu diesem Buch
Inhaltsverzeichnis |
Index |
Probekapitel |
Kolophon |
Rezensionen |
Index
[ Symbols ], [ Numbers ], [ A ], [ B ], [ C ], [ D ], [ E ], [ F ], [ G ], [ H ], [ I ], [ J ], [ K ], [ L ], [ M ], [ N ], [ O ], [ P ], [ Q ], [ R ], [ S ], [ T ], [ U ], [ V ], [ W ], [ X ], [ Z ]
Symbols[ Top ]
\ (backslash), 21
in regular expressions, 92
{} (braces) (regular expressions), 90
[ ] (brackets)
in regular expressions, 88
client side scripts and, 197
. (dot operator), 27
== (double-equal operator), 31
$ (end anchor) (regular expressions), 89
== (equality operator)
string comparisons and, 81
=> (equal-to or greater-than operator), 60
/* and */ (multi-line comments), 20
// (one-line comments), 20
# (one-line comments), 20
=== (is-identical operator), 41
!== (is-not-identical operator)), 41
* (matching operator) (regular expressions), 90
+ (matching operator) (regular expressions), 90
? (matching operator) (regular expressions), 90
% (modulo function), 510
!= (not equals operator), 31
^ (not operator) (regular expressions), 89
<=> (NULL-safe equality comparison operator), 506
<?php and ?> script tags, 18
^ (start anchor) (regular expressions), 89
Numbers[ Top ]
4/5 rounding rules, 104
A[ Top ]
abs( ) function (MySQL), 510
abs( ) function (PHP), 103
absolute URLs, 719
absolute values, 103
abstract classes (PHP 5), 462-465
acos( ) function (MySQL), 510
addtocart.php (winestore database), 545, 597, 603, 609-613
Adobe
Adobe Reader, 424
PDF (see PDF)
PostScript, 425
aggregation, 156
alert( ) method (JavaScript), 312
aliases, 485-487
alice.inc include file, 432
ALL statement, 529
anchors, 89
Apache
HTTP authentication using, 372-375
Linux
checking for installation on, 669
installing on, 675-680
secure server installation, 676-678
standard server installation, 678-680
Mac OS X
installation on, 702-705
secure server installation, 705-708
web servers, 7
Windows, installing on (see EasyPHP)
array( ) function (PHP), 58
array( ) language construct, 58
array_fill( ) function (PHP), 66
array_key_exists( ) function (PHP), 69
array_merge( ) function (PHP), 70
array_reverse( ) function (PHP), 71
arrays, 57-76
array order, 60
associative arrays, 59
basic array functions, 65-76
creating, 58
definition, 57
destroying, 60
foreach statement, traversing with, 63
heterogenous arrays, 61
keys and values, 69
multidimensional arrays, 61-63
removing elements from, 60
sorting, 71-76
associative arrays, 74
based on user-defined criteria, 75
on keys, 74
sort( ) and rsort( ), 71-73
superglobals, 195
array_search( ) function (PHP), 68
arsort( ) function (PHP), 74
asin( ) function (MySQL), 510
asort( ) function (PHP), 74
assignment (=) and equality (== operators), compared, 32
associative arrays, 59
sorting of, 74
atan( ) function (MySQL), 510
attributes, 136, 137, 145
data types, 136
modifiers, 146
auth/changepassword.php (winestore database), 547, 647, 664, 665
authenticated( ) function (PHP), 375, 377
authenticate.inc (winestore database), 646, 647
authenticateUser( ) function (PHP), 383, 391
authentication, 369-401
authentication databases, 379-385
authentication process, 383
password encryption in, 379
form-based, 385-397
HTTP authentication, 369-373
advantages, 385
disadvantages, 385
PEAR packages for, 247
session hijacking, 387
prevention, 387
session-based applications and, 386-397
session-based framework, 388-397
authentication.inc file, 390
authentication.inc file (winestore database), 659-661
auth/logincheck.php (winestore database), 547, 646, 661, 662
auth/login.php (winestore database), 547, 646, 661
auth/logout.php (winestore database), 548, 646, 661, 663
auth/password.php (winestore database), 547, 647, 664, 665
AVG( ) function (MySQL), 157
B[ Top ]
backslash (\), 21
inclusion in double-quoted strings, 21
backslash (\) (regular expressions), 92
backTrace( ) function (PHP), 416
base classes, 124, 126
<base> element (HTML), 719
benchmarking PEAR packages, 247
BETWEEN operator, 507
bindec( ) function (PHP), 104
blocks, 234
bookmarks and sessions, 359
Boolean variables, 25
braces ({}) (regular expressions), 90
brackets ([ ]), 197
brackets ([ ]) (regular expressions), 88
branching statements, 28-33
C[ Top ]
caching PEAR packages, 247
callback functions, 76
cardinalities, 732
cart/addtocart.php (winestore database), 545, 597, 603, 609-613
cart/emptycart.php script (winestore database), 613
Cartesian products, 161
cart/showcart.php (winestore database), 548, 597, 606, 614
cart/updatecart.php (winestore database), 548, 597, 608, 614-617
case, changing in strings, 80
CaseCounter object, 469
catch statement, 131
(see also try...catch statement)
ceil( ) function (PHP), 104
ceiling( ) function (MySQL), 510
Cezpdf( ) method (pdf-php), 428
Cezpdf::Cezpdf( ) class constructor (pdf-php), 440
Cezpdf::ezColumnsStart( ) method (pdf-php), 441
Cezpdf::ezColumnsStop( ) method (pdf-php), 441
Cezpdf::ezImage( ) method (pdf-php), 441
Cezpdf::ezInsertMode( ) method (pdf-php), 442
Cezpdf::ezNewPage( ) method (pdf-php), 443
Cezpdf::ezOutput( ) method (pdf-php), 443
Cezpdf::ezSetCmMargins( ) method (pdf-php), 443
Cezpdf::ezSetDy( ) method (pdf-php), 443
Cezpdf::ezSetMargins( ) method (pdf-php), 443
Cezpdf::ezSetY( ) method (pdf-php), 443
Cezpdf::ezStartPageNumbers( ) method (pdf-php), 443
Cezpdf::ezStopPageNumbers( ) method (pdf-php), 444
Cezpdf::ezStream( ) method (pdf-php), 444
Cezpdf::ezTable( ) method (pdf-php), 444
Cezpdf::ezText( ) method (pdf-php), 449
challenge method, 371
changepassword.php (winestore database), 547, 647, 664, 665
character encoding, 23
characters, replacing in strings, 85-87
checkdate( ) function (PHP), 102, 303
checkpoints, 519
class diagrams, 124
class references, 119
class type hints (PHP 5), 131, 462
classes, 109
defining with include files, 112
class.ezpdf.php, 427
class.pdf.php, 427
ClibPDF, 424
client tier, 3
thickening the client, 6
client-server architecture, 2
client-side validation, 287
advantages, 307
cloning objects, 122-123
close( ) function (PHP), 751
code examples
Linux installation, 683
Mac OS X installation, 709
Windows installation, 694
columns, 136, 178
command interpreter (MySQL), 140-142
compareDates( ) method, 306
comparison operators, 506
compound types, 24
concat( ) function (MySQL), 505, 508
concat_ws( ) function (MySQL), 508
concurrency, 271
concurrent access, 10
conditional expressions, 31
conditional statements, 28-33
confirm( ) method (JavaScript), 312
connection resource, 173
console PEAR packages, 247
constants, 25
constraints, 138, 727
constructors, 113-115
control flow functions (MySQL), 512
cookies, 339
cos( ) function (MySQL), 510
COUNT( ) function (MySQL), 157
count( ) function (PHP), 65
Cpdf::addDestination( ) method (pdf-php), 450
Cpdf::addInfo( ) method (pdf-php), 450
Cpdf::addInternalLink( ) method (pdf-php), 451
Cpdf::addJpegFromFile( ) method (pdf-php), 451
Cpdf::addLink( ) method (pdf-php), 451
Cpdf::addObject( ) method (pdf-php), 451
Cpdf::addPngFromFile( ) method (pdf-php), 452
Cpdf::addText( ) method (pdf-php), 452
Cpdf::closeObject( ) method (pdf-php), 452
Cpdf::curve( ) method (pdf-php), 452
Cpdf::ellipse( ) method (pdf-php), 452
Cpdf::filledRectangle( ) method (pdf-php), 453
Cpdf::getFontDecender( ) method (pdf-php), 453
Cpdf::getFontHeight( ) method (pdf-php), 453
Cpdf::getTextWidth( ) method (pdf-php), 453
Cpdf::line( ) method (pdf-php), 453
Cpdf::openHere( ) method (pdf-php), 453
Cpdf::openObject( ) method (pdf-php), 453
Cpdf::partEllipse( ) method (pdf-php), 454
Cpdf::polygon( ) method (pdf-php), 454
Cpdf::rectangle( ) method (pdf-php), 454
Cpdf::reopenObject( ) method (pdf-php), 454
Cpdf::selectFont( ) method (pdf-php), 454
Cpdf::setColor( ) method (pdf-php), 455
Cpdf::setEncryption( ) method (pdf-php), 455
Cpdf::setLineStyle( ) method (pdf-php), 455
Cpdf::setPreferences( ) method (pdf-php), 456
Cpdf::setStrokeColor( ) method (pdf-php), 456
Cpdf::stopObject( ) method (pdf-php), 456
Cpdf::transaction( ) method (pdf-php), 456
CREATE DATABASE statement, 142
CREATE TABLE statement, 143-147
ER modeling and, 738
KEY clause and, 532
SELECT, using with, 500
credit card validation, 298-301
crypt( ) function (PHP), 380
md5( ), compared to, 382
curdate( ) function (MySQL), 511
current timestamps, 97
curtime( ) function (MySQL), 511
customer purchasing report, outputting, 435
customer/details.php (winestore database), 546, 547, 584, 586, 591-593
customer/receipt.php (winestore database), 547, 584, 586, 593-595
customer/validate.php (winestore database), 547, 584, 586, 587-590
customHandler( ) function (PHP), 413
customHandler.inc (winestore database), 574-576
custreceipt.tpl (winestore database), 595
D[ Top ]
data source name, 225
data types (MySQL), 136
data types (see types)
data versioning, 518
database( ) function (MySQL), 513
database servers, 135
reasons for using, 13
database tier, 3, 10
databases, 134-170
altering, 497
authentication, using for, 379-385
backup and recovery, 522-525
mysqldump, 523
restoring databases, 524
selective backups, 524
bulk loading files into, 502
connecting to and querying, scripting for, 172-175
creating, 142
data, working with, 148-152
deleting, 151
inserting, 148-151
updating, 151
database management systems (see DBMSs)
definition, 137
delayed insertions, 503
deleting data, 270, 503
designing, 726
exportation of data, 527
INSERT, using with SELECT, 499
inserting data, 260-265, 498
data entry, 261
data validation, 263
receipt page, 265
inserts, updates, and deletes, 251-270
join queries, 160-168
managing, 142-148
MySQL, 135
command interpreter, 140-142
PEAR packages for, 248
query caching, 538-540
reloading data, 255
replacing data, 501
SELECT queries (see SELECT statement)
table types, 516-522
tables, checking and repair, 525-527
tables, creating, 143-147
based on ER modeling, 738-745
tables, deleting, 147
terminology, 137
transactions and concurrency, 270-272
tuning, 532-540
index design, 532-536
updating data, 265-270, 505
case study, 266-270
user accounts and privileges, managing, 527-531
users, creating, 528
winestore database, 138
date( ) function (PHP), 100, 306
date formats, 301
date functions, 97-103
formatting a date, 100
formatting characters, 100
date PEAR package, 248
date validation, 102, 301-303
birthday validation, 302
Easter, 302
date_add( ) function (MySQL), 511
date_format( ) function (MySQL), 512
DB::affectedRows( ) function, 226
DB::connect( ) function, 225, 226
DB::createSequence( ) function, 227
DB::dropSequence( ) function, 227
DB::fetchRow( ) function, 225
db.inc require file, 183
db.inc (winestore database), 569
DB::isError( ) function, 225, 228
DBMSs (database management systems), 3, 11-15, 135, 138
MySQL, 14
DB::nextId( ) function, 228
DB::nextId( ) method, 282
DB.php, inclusion in path, 224
DB::query( ) function, 225, 228
DB::quote( ) function, 228
DB_Result::fetchRow( ) function, 227
DB_Result::numRows( ) function, 228
DB_Result::tableInfo( ) function, 229
debug_backtrace( ) function (PHP), 416
decbin( ) function (PHP), 104
dechex( ) function (PHP), 104
decoct( ) function (PHP), 104
decode( ) function (MySQL), 513
DEFAULT modifier, 146
DELAYED modifier, 503
DELETE request (HTTP), 721
DELETE statement, 151, 503
descendant classes, 127
destroy( ) function (PHP), 751
destructors, 115
details.php (winestore database), 546, 547, 584, 586, 591-593
die( ) function (MySQL), 176
digests, 380
dirty reads, 271
displayCart( ) function (winestore database), 607
DISTINCT clause, 165, 167
Document Object Model (see DOM)
DOM (Document Object Model), 314-316
dot (.) operator, 27
double-equal (==) operator, 31
doublevalue( ) function (PHP), 49
DROP statement, 147
E[ Top ]
EasyPHP, 689-693
echo statement, 20
ECMA-SCRIPT
(see also JavaScript)
ECMA-Script, 307
elementary natural joins, 162
elements, 57
else clause, 29
email address validation, 292-295
empty( ) language construct, 42
encode( ) function (MySQL), 513
encoding standards, 23
web sites, 24
encryption functions (MySQL), 512
encryption of passwords, 379-382
end anchors ($) (regular expressions), 89
entities, 137, 726
identifying, 729
entity-relationship (ER) modeling, 137, 138
entity-relationship modeling (see ER modeling)
equality operator
assignment operator, compared to, 32
SQL compared to PHP, 506
equal-to or greater-than (=>) operator, 60
ER (entity-relationship) modeling, 137, 138, 728-740
converting to SQL, 738-745
entities, 726
identifying, 729
ER diagrams, 729
identifying relationships, 732
key attributes, identifying, 736
multivalues attributes, 738
tools, 729, 737, 738
weak entities, 737, 738
ereg( ) function (PHP), 88, 94
eregi( ) function (PHP), 94
eregi_replace ( ) function (PHP), 95
ereg_replace( ) function (PHP), 95
error handling of MySQL functions, 176-178
errors, 402-412
basic custom handlers, 412-415
disadvantages, 415
common programming errors, 407-410
partial or no page output, 407
variables, 408-410
custom error handlers, 412-421
less common problems, 410
header complaints, 410
missing semicolons, braces, and quotes, 411
source shown in browsers, 411
PHP error constants, 403
PHP Manual, 405
production error handlers, 415-421
including debugging information, 415-417
logging and user notification, 417-419
triggering errors, 419-421
reporting, configuration of, 406
templates and, 405
escape sequences, 21
variables and, 23
escaping special characters in regular expressions, 92
events, 308
in JavaScript, 316
Exception class, 132
exceptions, throwing and catching, 131-133
exec( ) function (PHP), security risks, 198
EXISTS clause, 489-492
EXPLAIN statement, 533
explode( ) function (PHP), 66
split( ) and spliti( ) functions, compared to, 96
exponential functions, 105
expressions, 26
extends keyword, 457
extract( ) function (MySQL), 511
ezColumnsStart( ) method (pdf-php), 431
ezImage( ) method (pdf-php), 432
EZPDF class, 440
ezSetDy( ) method (pdf-php), 431
ezStartPageNumbers( ) method (pdf-php), 431
ezStream( ) method (pdf-php), 428
ezTable( ) method (pdf-php), 434
ezText( ) method (pdf-php), 428, 431
F[ Top ]
fatal errors, 403
fields, 136, 178
filesystem PEAR packages, 248
final functions, 130
float data type, 25
floating numbers, 103-107
floatval( ) function (PHP), 37
floor( ) function (MySQL), 510
floor( ) function (PHP), 104
foreach statement (PHP), 63
format( ) function (MySQL), 510
format strings, 77
formatting characters
for date( ) function, 100
strftime( ) and gmstrftime( ) functions, 101
form-based authentication, 385-397
forms, processing of data from, 196-198
fragment identifiers, 718
freight calculator example, 469-478
class diagram, 478
deliverable interface, 470
improved calculator, 471-475
using, 475-477
FreightCalculator objects, 469
FROM clause, 492
functions, 36
absolute value, 103, 510
array library functions, 65-76
callback functions, 76
ceiling and floor, 104, 510
constructor functions, 114
date and time functions, 97-103
destructor functions, 115
final functions, 130
for testing number results, 106
IT and ITX functions, 245
member functions, 111
MySQL, 208-218
for error handling, 176-178
number system conversions, 104
PEAR DB, 226-229
powers and logs, 105
private member functions, 117
protected functions, 129
random number generation, 106
redefined functions, 127-129
regular expression functions, 94-97
rounding, 104
static member functions, 121
string functions, 76-87
trigonometric functions, 105
user-defined (see user-defined functions)
G[ Top ]
garbage collection, PHP Windows sessions, 364
gc( ) function (PHP), 751
GET method, 191, 721
get_class( ) function (PHP), 461
getCode( ) function (PHP), 132
getCust_id( ) function (winestore database), 581
getFile( ) function (PHP), 132
gethostbyname( ) function (PHP), 294
getLine( ) function (PHP), 132
getMessage( ) function (PHP), 132
getmxrr( ) function (PHP), 294
get_parent_class( ) function (PHP), 461
getrandmax( ) function (PHP), 107
gettype( ) function (PHP), 41
ghostview, 424
global variables, 47
gmdate( ) function (PHP), 100
gmmktime( ) function (PHP), 97
gmstrftime( ) function (PHP), 101
GRANT OPTION statement, 528
GROUP BY clause, 156, 496
Gtk packages, 220
H[ Top ]
hash arrays, 60
hash indexes, 522
HAVING clause, 157
HEAD request (HTTP), 721
header( ) function (PHP), 206
headers, 5
heap tables, 522
heterogenous arrays, 61
hexadecimal encoding sequences, 23
hexdec( ) function (PHP), 104
high-bit characters, 23
homepage (winestore database), 598-604
home.php script, 392
home.tpl template, 393
htaccess file, 373
HTML forms for user input, 252-255
HTML Integrated Templates (IT) package (see IT package)
HTML PEAR packages, 248
HTML report output format, 425
HTML_Template_IT package (see IT package)
HTML_Template_ITX package (see ITX package)
HTML_ToPDF, 425
HTTP (Hypertext Transfer Protocol), 4, 716-725
authentication, 369-373
PHP, 373-385
GET method, 191
HTTP requests, 720-722
GET versus POST, 722
request methods, 721
HTTP responses, 722-724
caching, 724
status codes, 723
PEAR packages for, 249
POST method, 191
request, 5
response, 5
URLs (see URLs)
httpd.conf configuration file, 372
I[ Top ]
identifiers table, 280
if function (MySQL), 512
if statement, 28
if...else statement, 28-30
implode( ) function (PHP), 66
IN clause, 488
in_array( ) function (PHP), 67
include files, 51-53
defining classes with, 112
managing, 52
tagging requirements, 51
includes/authenticate.inc (winestore database), 646, 647
includes/customHandler.inc (winestore database), 574-576
includes/db.inc (winestore database), 569
includes/template.inc file (winestore database), 563
includes/validate.inc (winestore database), 569-574
includes/winestore.inc (winestore database), 576, 576-582
incorrect summary problem, 272
indexes, 58, 138
design, 532-536
tips, 535
index.php (winestore database), 545, 598, 601
index.tpl (winestore database), 602
inheritance, 124-131, 457
inner queries, 487
InnoDB tables, 519
COMMIT and ROLLBACK transactions, 520
disadvantages, 520
INSERT DELAYED statement, 276
INSERT statement, 148-151
using with SELECT, 499
instanceof keyword (PHP 5), 461
instances, 110
integer data type, 25
integers, 103-107
interactive validation, 286
client-side versus server-side, 286
interfaces (PHP 5), 465-468
internationalization
PEAR packages for, 249
intval( ) function (PHP), 37
IP addresses, 715
is_a( ) function (PHP), 461
is_finite( ) function (PHP), 106
isFutureDate( ) method (PHP), 305
is-identical (===) operator, 41
is_nan( ) function (PHP), 106
is-not-identical(!==) operator, 41
is_numeric( ) function (PHP), 296
ISO-8859-1 encoding standard, 23
isset( ) function (PHP), 42
is_string( ) function (PHP), 289
is_subclass_of( ) function (PHP), 461
isValidDate( ) method (PHP), 305
IT (Integrated Templates) package, 230, 232-243
blocks, 233-243
nested blocks, 237-243
optional blocks, 241-243
preserving and removing, 240
functions, 245
placeholders, 233
ITX (Extended Integrated Templates) package, 243
functions, 245
J[ Top ]
JavaScript, 7, 307
client-side validation using, 307-337
debugging, 313
DOM (Document Object Model), 314-316
ECMA-Script and, 307
events, 316
examples, 320-326
browser identification, 324
browser interaction, 323
drop-down menus, 325
mouseover events, 321
password form validation, 320
prefilling form data with calculations, 322
functions, 313
generic validation function, 326-337
loops and conditionals, 312
methods and properties, 317
navigator object, 317-320
objects, 314
old browsers and, 310
PHP, compared to, 310-313
syntax, 311
validation example, 308-310
web database applications, uses in, 308
join( ) function (PHP), 66
join queries, 160-168
advanced types, 481-485
Cartesian products, avoiding, 161
elementary natural, 162
inner joins, 482
left and right joins, 483
natural joins, 482
with more than two tables, 165
K[ Top ]
KEY clause, 532
keys, 57, 146
primary keys, 136
krsort( ) function (PHP), 74
ksort( ) function (PHP), 74
L[ Top ]
Latin-1 encoding, 23
legal character tests, 289-290
length( ) function (MySQL), 508
length validation, 289
LIKE, 508
LIMIT operators, 160
Linux
checking for installed applications, 667-671
installing applications, 671-687
Apache, 675-680
code examples, 683
MySQL, 671-675
OpenSSL, 676
PDF PHP library, 685
PEAR package, 683
PHP, 680-682
winestore application, 686
winestore database, 685
ln( ) function (MySQL), 510
load balancing, 746
LOAD DATA INFILE statement, 503
load-time errors (JavaScript), 313
locate( ) function (MySQL), 508
LOCK TABLES statement, 275
previous locks, and, 276
locking, 273
avoiding through query design, 275
concurrency and, 279
improper methods for web databases, 278
INSERT DELAYED and, 276
performance and, 276
log( ) function (MySQL), 510
log10( ) function (MySQL), 510
logarithmic functions, 105
logging PEAR packages, 249
logincheck.php script, 389
logincheck.php (winestore database), 547, 646, 661, 662
login.html page, 389
login.php (winestore database), 547, 646, 661
logout.php script, 393
logout.php (winestore database), 548, 646, 661, 663
loops, 33-36
lower( ) function (MySQL), 509
LOW_PRIORITY WRITEs, 276
ltrim( ) function (MySQL), 508
ltrim( ) function (PHP), 80
M[ Top ]
Mac OS X
Apache set-up, 702-705
secure server installation, 705-708
HTTP Apache auth directory, 373
installing applications, 698-713
code examples, 709
MySQL, 699-702
PDF PHP library, 710
PEAR packages, 708
winestore application, 712
winestore database, 711
OpenSSL key and certificate creation, 706
PEAR installation and upgrade, 230
PEAR package inspection, 221
PHP set-up, 703-705
PHP upgrade, 705
root user, unlocking, 698
mail( ) function (PHP), 636
mail PEAR packages, 249
Mail::factory( ) method, 636
many-to-many relationships, 733, 735, 745
MAX( ) function (MySQL), 157
max( ) function (PHP), 67
md5( ) function (MySQL), 513
md5( ) function (PHP), 380
crypt( ), compared to, 382
MD5 Message Digest Algorithm, 380
member functions, 109, 111
private member functions, 117
static member functions, 121
member variables, 109, 111
private member variables, 116
protected member variables, 129
static member variables, 118-121
message digests, 380
metacharacters in regular expressions, 93
methods, 109
Microsoft RTF (Rich Text Format), 425
Microsoft Windows
automated querying, 515
HTTP Apache auth directory, 373
installing applications
EasyPHP, 689-693
PDF PHP library, 695
PEAR packages, 693
winestore application, 696
winestore database, 695
installing web database applications, 688-697
code examples, 694
PEAR installation and upgrade, 231
PEAR package inspection, 222
report output formats, 422
sessions, PHP garbage collection on, 364
microtime( ) function (PHP), 99
middle tier, 3, 7
MIN( ) function (MySQL), 157
min( ) function (PHP), 67
mktime( ) function (PHP), 97, 303
mod( ) function (MySQL), 510
modifiers, 146
modulo function, MySQL, 510
multidimensional arrays, 61-63
multivalued attributes, 738
MyISAM tables, 518
MySQL, 11, 14, 135
advanced features, 479-540
advanced querying, 481-497
aliases, 485-487
backup and recovery, 522-525
command interpreter, 140-142
control flow functions, 512
date functions, 511
encryption functions, 512
functions, 208-218, 505
error handling, 176-178
functions to avoid, 218
GROUP BY clause, 496
improved function library, 766-778
basic features, 771
inserting data, 772-775
installation, 768
migration of legacy code, 768
new features, 766
profiling queries, 777
queries, 772-777
retrieving data, 775-777
Linux, installing on, 668, 671-673
booting up, 674
LOAD DATA INFILE statement, 503
Mac OS X, installing on, 699-702
nested queries, 487-492
privileges, managing, 527-531
procedures, 497
query caching, 538-540
session store (see MySQL session store)
stable releases, 172
stored procedures, 497
string functions, 507
time functions, 511
tuning, 532-540
index design, 532-536
unique capabilities, 479
user accounts, managing, 527-531
Version 4, 14
Windows, installing on (see EasyPHP)
WITH ROLLUP modifier, 495-496
MySQL session store, 751-760
handler implementations, 752
garbage collection handler, 757
getMicroTime( ) function, 753
registering session handlers, 758
session close handler, 757
session destroy handler, 757
session open handler, 753
session read handler, 754
session write handler, 755
showerror( ) function, 753
trigger_error( ) function, 753
session table structure, 751
mysqladmin tool, 537
mysqlclean( ) function (PHP), 198
mysqldump
selective backups, 524
mysqldump command, 523
mysqlhotcopy tool, 523
mysql_affected_rows( ) function (PHP), 208
mysql_client_encoding( ) function (PHP), 214
mysql_close( ) function (PHP), 214
mysql_connect( ) function (PHP), 173, 209
mysql_data_seek( ) function (PHP), 214
mysql_errno( ) function (PHP), 176, 209
mysql_error( ) function (PHP), 176, 209
mysql_fetch_array( ) function (PHP), 174, 175, 209-211
mysql_fetch_field( ) function (PHP), 178, 215
mysql_fetch_lengths( ) function (PHP), 216
mysql_fetch_object( ) function (PHP), 216
mysql_free_result( ) function (PHP), 216
mysql_get_client_info( ) function (PHP), 216
mysql_get_host_info( ) function (PHP), 216
mysql_get_proto_info( ) function (PHP), 217
mysql_get_server_info( ) function (PHP), 217
mysql_info( ) function (PHP), 217
mysql_insert_id( ) function (PHP), 211
mysql_list_processes( ) function (PHP), 217
mysql_num_fields( ) function (PHP), 217
mysql_num_rows( ) function (PHP), 211
mysql_pconnect( ) function (PHP), 209, 212
mysql_ping( ) function (PHP), 217
mysql_query( ) function (PHP), 174, 213
mysql_real_escape_string( ) function (PHP), 212
mysql_select_db( ) function (PHP), 173, 213
mysql_thread_id( ) function (PHP), 217
mysql_unbuffered_query( ) function (PHP), 213
N[ Top ]
natural joins, 162
navigator objects (JavaScript), 314, 317-320
nested queries, 487-492
EXISTS clause, 489-492
IN clause, 488
in FROM clauses, 492
networking PEAR packages, 249
newline characters in PHP scripts, 21
newUser( ) function (PHP), 647
normalization, 138
not (^) operator (regular expressions), 89
NOT BETWEEN operator, 507
not equals (!=) operator, 31
NOT NULL modifier, 146
now( ) function (MySQL), 511
nulls, 24
NULL-safe equality comparison operator (<=>), 506
number system conversions, 104
O[ Top ]
object-oriented programming, 108-133
class hierarchies, 457-460
classes, 109
defining with include files, 112
cloning objects, 122-123
constructors, 113-115
destructors, 115
exceptions, throwing and catching, 131-133
freight calculator example, 469-478
class diagram, 478
deliverable interface, 470
improved calculator, using, 475-477
improving, 471-475
inheritance, 124-131, 457
instances, 110
member functions, 109, 111
member variables, 109, 111
methods, 109
objects, 108
parent constructors, 126
PHP 5, 457-478
abstract classes, 462-465
class type hints, 462
interfaces, 465-468
polymorphism, 460
private member functions, 117
private member variables, 116
protected member variables and functions, 129
static member functions, 121
static member variables, 118-121
objects, 108
cloning, 122-123
octal encoding sequences, 23
octdec( ) function (PHP), 104
ON clause, 482
one-component querying, 189, 205-207
one-to-many relationships, 732, 735, 743
one-to-one relationships, 732, 735, 743
open( ) function (PHP), 750
OpenSSL
key and certificate creation, 677
key and certificate creation, Mac OS X, 706
Linux installation, 676
operators, 26
precedence, 28
OPTIMIZE TABLE statement, 504
ORDER BY clause, 155, 167
order/order-step1.php (winestore database), 549
order/order-step2.php (winestore database), 549
order/order-step3.php (winestore database), 549
order/order-step4.php script (winestore database), 630-634
order/order-step4.php (winestore database), 549
order/receipt.php script (winestore database), 637-640
order/receipt.php (winestore database), 549
outer queries, 487
P[ Top ]
padding strings, 79
parent classes, 124
parent constructors, 126
parent:: reference operator, 128
parsing, 22
passthru( ) function (PHP), security risks, 200
password( ) function (MySQL), 513
password.php script, 395
password.php (winestore database), 547, 647, 664, 665
PCRE (Perl Compatible Regular Expression) syntax, 87
PDF PHP library
installation
Mac OS X, 710
Linux installation, 685
PDF (Portable Document Format), 423
characteristics, 428
producing, 427-440
full-featured documents, 428-432
"Hello, world", 427
pdf-php library, 427
PDF-PHP reference, 440-456
base class, 450-456
EZPDF class, 440-449
PEAR (PHP Extension and Application Repository), 9, 219-250
core components, 220-229
Unix installation, checking, 221
Windows installation, checking, 222
current release, 219
optional packages, 247-250
package installation
Linux, 683
Mac OS X, 708
Windows, 693
packages, 230-250
documentation, 230
included in, 219
installing, 220, 230
IT package (see IT package)
manual installation, 232
release states, 231
upgrades, 232
PEAR Date package, 305
PEAR DB, 222-229
advantages and disadvantages, 223
connection, query, and results retrieval, 223
data source name, specification, 226
error handling, 225
functions for MySQL, 226-229
identifiers, managing with, 282
PEAR HTTP_Session module, 760
PEAR ITX template class, use in winestore database, 551
PEAR Mail package, 636
PEAR Net_DNS package, 294
web site, 231
pearclean( ) function (winestore database), 581
PECL, 220
Perl Compatible Regular Expression (PCRE) syntax, 87
phonebook database, 353
deleting data, 270
HTML template, 261-263
identifiers table, 280-284
locking, 276-284
new entry form
complete script, 354-357
error messages, 354
improvements, 348-357
previously entered values, displaying, 353
updating data, 266-270
PHP, 8, 16-56
arrays (see arrays)
character encoding, 23
comments, 20
conditionals and branches, 28-33
constants, 25
creating scripts, 19
database connections, scripting, 172
directory permissions and locations, 19
echo statement, 20
expressions, 26
functions, 36
"Hello World", 17
HTTP authentication, 373-385
JavaScript, compared to, 310-313
language features, 18
Linux installation, 670, 680-682
loops, 33-36
Mac OS X installation, 703-705
newline characters in scripts, 21
operator precedence, 28
outputting data, 20
parsing, 22
of single- and double-quoted strings, 22
PEAR (see PEAR)
PHP Manual, 405
print statement, 20
programming editors, 19
script tags, beginning and ending, 18
scripting example, 53-56
server-side validation, 287-307
session management, 340-347, 747-751
destroying sessions, 749
session handlers and load balancing, 746
session support layers, 748
storage methods, 749
user-defined storage handlers, 750
stable releases, 172
string expressions, 27
string literals, 21
strings (see strings)
types (see types)
user-defined functions (see user-defined functions)
variable substitution, 22
variables, 24
versions, 9
web pages and, 16
Windows, installing on (see EasyPHP)
PHP Extension and Application Repository (see PEAR)
.php file extension, 19
PHP: PDFlib, 424
PHP5, 9
php.ini file and session configuration, 365
pi( ) function (MySQL), 510
polymorphism, 460
Portable Document Format (see PDF)
ports, 716
POSIX character classes, 94
POSIX extended regular expression syntax, 87
POST method, 191
POST request (HTTP), 721
postcode validation, 290-292
PostScript, 425
post-validation, 286
pow( ) function (MySQL), 510
<pre> tags, 59
precedence, 28
primary keys, 136, 138, 736
print statement, 20
printf( ) function (PHP), 77
supported conversion types, 78
printing reports (see reporting)
print_r( ) function (PHP), 41
including output in web page, 59
private member functions, 117
private member variables, 116
privileges
granting, 528
management in MySQL, 531
network access, 530
revoking, 531
scope and, 528
protected functions, 129
protected member variables, 129
pseudo-random numbers, 106
PUT request (HTTP), 721
Q[ Top ]
queries, 166
automating, 513-516
Unix, 514
Windows, 515
indexes and, 532
join queries (see join queries)
locks, avoiding through design, 275
nested queries, 487-492
on MySQL with PHP, 172-188
error handling, 176-178
formatting results, 180-183
mysql_fetch_array( ) function, 175
opening a database connection, 172-175
security concerns, 198-202
select lists on HTML forms, 184-188
table structures, 178-180
one-component querying, 189, 205-207
user input, generating from, 203-207
user-driven querying, 188
query caching, 538-540
QUICK modifier, 504
quote( ) function (MySQL), 508
R[ Top ]
rand( ) function (MySQL), 510
rand( ) function (PHP), 106
random numbers
generating seeds for, 99
range( ) function (PHP), 66
rawurlencode( ) function (PHP), 658, 720
read( ) function (PHP), 750
realm, 371
receipt.php (winestore database), 547
records, 136
redefined functions
object-oriented programming
redefined functions, 127-129
regular expressions, 87-97
\ (backslash), 92
{ } (braces), 90
[x12] (brackets), 88
$ (end anchor), 89
* (matching operator), 90
+ (matching operator), 90
? (matching operator), 90
^ (not operator), 89
^ (start anchor), 89
alternative patterns, 92
anchors, 89
character lists, 88
using, 92
character ranges, specifying, 88
functions, 94-97
groups, 91
metacharacters, 93
POSIX character classes, 94
special characters, escaping, 92
syntax, 87
relational databases, 135, 726-745
constraints, 727
entities, 726
ER modeling (see ER modeling)
many-to-many relationships, 733, 735, 745
one-to-many relationships, 732, 735, 743
one-to-one relationships, 732, 735, 743
winestore example, 726-728
relational models, 138
relative URLs, 719
reload problem, 255-260
replace( ) function (MySQL), 508
reporting, 422-456
"Hello, world", 427
output formats, 423-426
choosing, 422
output formats
email and plaintext, 426
HTML and XML, 425
PDF (see PDF)
PostScript, 425
RTF (Rich Text Format), 425
PDF-PHP reference, 440-456
base class, 450-456
EZPDF class, 440-449
producing full-featured documents, 428-432
creating reports, 435-440
database example, 432-435
fonts, 430
require directives, 52, 183
result set resource, 174
REVOKE statement, 531
Rich Text Format (RTF), 425
R&OS Ltd's PHP PDF library, 427
round( ) function (MySQL), 510
round( ) function (PHP), 104
rows, 136, 137
rsort( ) function (PHP), 71-73
RTF (Rich Text Format), 425
rtrim( ) function (MySQL), 508
rtrim( ) function (PHP), 80
run-time errors (JavaScript), 313
RustyPart's HTML_ToPDF, 425
S[ Top ]
salt, 380
scalar types, 24
scripting languages
JavaScript, 7
PHP (see PHP)
search/searchform.php (winestore database), 546, 549, 643, 644, 648
search/search.php (winestore database), 549, 643, 644, 649-654
search.tpl (winestore database), 655, 656
Secure Sockets Layer protocol (see SSL)
security
attacks and special characters, 200
authentication (see authentication)
queries from user input, 198-202
sessions and, 360
users and privileges, managing, 527-531
validation and, 287
SELECT ... INTO OUTFILE statement, 527
<select multiple> tag, 196
SELECT statement, 152-160
arithmetic and comparison operators, 506
clauses, combining, 158
CREATE TABLE, using with, 500
DISTINCT clause, 159
HAVING clause, 157
INSERT, using with, 499
LIMIT operators, 160
ORDER BY clause, 155
sorting and grouping output, 155
WHERE clause, 153
selectDistinct( ) function (MySQL), 187
selectFont( ) method (pdf-php), 430
Sequel, 11
server variables, 195
$_SESSION array, 341
sessionAuthenticate( ) function (PHP), 388, 391, 648
sessionClose( ) handler function, 757
session_destroy( ) function (PHP), 344, 361
session_destroy( ) handler function, 757
sessionGC( ) garbage collection handler, 757
session_id( ) function (PHP), 361
session_is_registered( ) function (PHP), 361
sessionOpen( ) handler function, 753
sessionRead( ) handler function, 754
session_readonly( ) function (PHP), 361
session_register( ) function (PHP), 361
sessions, 6, 338-368
advantages, 357
authentication and, 386-397
bookmarks and, 359
cookies, 339
definition, 339
disadvantages, 358
ending, 344
hijacking, prevention, 387
management, 340-347
configuration, 365-368
garbage collection, 364
without cookies, 362-364
(see also PHP, session management)
performance, 359
PHP accessing functions, 360-362
with register_globals enabled, 361
PHP API and configuration, 360-368
security aspects, 360
session hijacking, 387
session identifiers, 341
session identifiers (IDs), 339
session variables, 195, 339, 341-344
serialization, 344, 749
storage, database tier, 746-760
types, 343
unsetting, 343
session-based applications, designing, 345-347
tracking anonymous users, 346
tracking authenticated users, 345
starting, 341
state information storage, 358
timeouts, 359
validation using, 347-357
when to use, 357-360
session_set_save_handler( ) function (PHP), 751, 758
session_start( ) function (PHP), 341-343, 360
session_unregister( ) function (PHP), 361
session_unset( ) function (PHP), 362
sessionWrite( ) handler function, 755
set_error_handler( ) function (PHP), 412
setupQuery( ) function (winestore database), 654
shapeInfo( ) function (PHP), 462
shellclean( ) function, 198, 200
shell_exec( ) function (PHP), security risks, 200
short-circuit evaluation property, 32
SHOW command (MySQL), 480
showcart.php (winestore database), 548, 597, 606, 614
showcart.tpl (winestore database), 607, 608
showCountry( ) function (winestore database), 582
showerror( ) function (PHP), 176
showPricing( ) function (winestore database), 581
showTitle( ) function (winestore database), 582
showVarieties( ) function (winestore database), 581
showWine( ) function (winestore database), 581
sin( ) function (MySQL), 510
Smarty PHP template engine, 233
SMTP (Simple Mail Transfer Protocol), 636
sort( ) function (PHP), 71-73
sorting arrays (see arrays, sorting)
special characters
escaping in regular expressions, 92
use in attacks, 200
sprintf( ) function (PHP), 77
supported conversion types, 78
SQL, 11, 135, 138
advanced querying, 481-497
arithmetic and comparison operators, 506
data types for attributes, 145
table creation based on ER modeling, 738-745
user variables, 493-495
(see also databases)
(see also MySQL)
sqrt( ) function (MySQL), 510
srand( ) function (PHP), 107
SSL (Secure Sockets Layer) protocol, 398-401
start anchors (^) (regular expressions), 89
starvation, 275
stateful versus stateless applications, 5
static member functions, 121
static member variables, 118-121
static variables, 47
storage engines (see tables types)
stored procedures, 497
strcasecmp( ) function (PHP), 81
strcmp( ) function (PHP), 81
strftime( ) function (PHP), 101
string expressions, 27
string functions (MySQL), 507
string literals, 21
strings, 21, 76-87
arrays, splitting into, 96
case, changing, 80
characters
replacing in, 85-87
translating, 86
trimming from, 80
comparing, 81
formatting, 77-81
length, 76
padding, 79
regular expressions, matching with (see regular expressions)
sprintf( ) and printf( ) functions (PHP), 77
supported conversion types, 78
substrings
extraction from strings, 81-85
replacing, 85-87, 95
translating, 86
timestamps, generating from date strings, 98
trimming whitespace, 80
validation of, 288-296
email addresses, 292-295
legal character tests, 289-290
validation of
URLs, 295
Zip and postcodes, 290-292
wildcard matching, 90
strlen( ) function (PHP), 76
strncasecmp( ) function (PHP), 81
strncmp( ) function (PHP), 81
str_pad( ) function (PHP), 79
str_replace( ) function (PHP), 86
strtolower( ) function (PHP), 80
strtotime( ) function (PHP), 98, 303
strtoupper( ) function (PHP), 37, 80
strtr( ) function (PHP), 86
strval( ) function (PHP), 37
substr( ) function (PHP), 290
substring( ) function (MySQL), 508
substrings (see strings, substrings)
substr_replace( ) function (PHP), 85
SUM( ) function (MySQL), 157
superglobals, 195
switch statement, 30
system( ) function (PHP)
security risks of, 200
T[ Top ]
tables, 137
attributes, 145
modifiers, 146
checking and repair, 525-527
creating, 143-147
deleting, 147
types, 516-522
tainted data, 198
tan( ) function (MySQL), 510
TCP/IP (Transmission Control Protocol/Internet Protocol), 714
telephone database
creating, 252
record creation, HTML form for, 252-255
reload problem and solutions, 255-260
templates/custreceipt.tpl (winestore database), 595
templates/details.tpl (winestore database), 561-563
templates/email.tpl (winestore database), 634
templates/index.tpl (winestore database), 602
templates/orderreceipt.tpl (winestore database), 640
templates/search.tpl (winestore database), 655, 656
templates/showcart.tpl (winestore database), 607, 608
templates/winestore.tpl (winestore database), 552
text editors, 19
thin clients, 6
three-tier architecture, web database applications, 3
throw statement, 131, 133
time( ) function (PHP), 97
time validation, 304
timestamp( ) function (MySQL), 512
timestamps, 97-99
generating from date strings, 98
subsecond timestamp functions, 99
TRACE request (HTTP), 721
transactions, 271
triggers, 497
trigonometric functions, 105
trim( ) function (MySQL), 508
trim( ) function (PHP), 80
truncate( ) function (MySQL), 510
TRUNCATE statement, 504
try...catch statement, 131, 133
two-phase locking, 273
two-tier architecture, 2
type-casting operators, 38
types, 24, 37-43
gettype( ), print_r( ), and var_dump( ) functions (PHP), 41
type conversion, 37
automatic conversion, 39
examples, 39
variables
boolean functions for type checking, 40-43
testing, setting, and unsetting, 42
U[ Top ]
uasort( ) function (PHP), 75
ucfirst( ) function (PHP), 80
ucwords( ) function (PHP), 80
uksort( ) function (PHP), 75
uniform resource identifiers, 717
uniform resource locators (see URLs)
union clause, 484
Unix
automated querying, 514
PEAR installation and upgrade, 230
PEAR package inspection, 221
report output formats, 423
UNLOCK TABLES statement, 274
necessary use of, 279
unregisterLogin( ) function (PHP), 647
unrepeatable reads, 272
unset( ) function (PHP), 42, 343
array elements, removing with, 60
update( ) function (JavaScript), 322
UPDATE statement, 151
joins and, 505
updatecart.php (winestore database), 548, 597, 608, 614-617
upper( ) function (MySQL), 509
URLs (uniform resource locators), 717-720
absolute and relative URLs, 719
fragment identifiers, 718
host and service identification, 717
nonstandard TCP ports, 717
parameters and queries, 718
protocol, 717
resource identification, 718
URL encoding, 720
validation of, 295
user( ) function (MySQL), 513
user input processing, 188-207
queries using, 203-207
tainted data, 198
user-driven querying, 188
user variables, 493-495
user-defined functions, 43-53
parameter types and return types, 45
reusing with include and require files, 50-53
variables, 46-48
passing to functions, 48-50
users, creating, 528
users table (winestore database), 584
USING clause, 482
usort( ) function (PHP), 75
V[ Top ]
validation, 285-337
client-side versus server-side, 287
client-side with JavaScript, 307-337
advantages, 307
debugging, 313
DOM, 314-316
events, 316
example script, 308-310
examples, 320-326
functions, 313
generic validation function, 326-337
JavaScript syntax, 311
loops and conditionals, 312
methods and properties, 317
navigator object, 317-320
objects, 314
common approaches, 286
effective models, 287
error reporting and, 285
ineffective models, 286
informative error messages, 348
post-validation models, 287
rekeying of data, avoiding, 351
server-side with PHP, 287-307
credit cards, 298-301
dates and times, 301-307
mandatory data, 288
numbers, 296-301
PEAR Date package, using, 305
strings, 288-296
time validation, 304
sessions and, 347-357
var_dump( ) function (PHP), 41
array values, displaying with, 61
variable substitution, 22
variables, 18, 24
destroying, 42
escape sequences and, 23
global variables, 47
passing to functions, 48-50
assigning by reference, 49
by reference, 48
default parameter values, 50
static variables, 47
types, 24
checking, 40-43
testing, setting, and unsetting, 42
variable assignment, 27
variable scope, 46-48
views, 497
W[ Top ]
weak entities, 737, 738
primary keys, 742
web browsers, 6
web database applications, 1
three-tier architecture, 3
web databases (see databases)
Web protocols, 714-725
HTTP (see HTTP)
IP addresses, 715
ports, 716
TCP/IP, 714
web servers, 2, 7
web services PEAR packages, 250
week( ) function (MySQL), 512
WHERE clause, 153, 166
whitespace, trimming from strings, 80
Windows (see Microsoft Windows)
winestore application
Linux installation, 686
Mac OS X installation, 712
Windows installation, 696
winestore database, 138
adding a wine, 168-170
application overview, 544-551
application templates, 551-568
authentication module, 545, 547, 645-648, 658-666
changing passwords, 664-666
users table, 645
browsing and searching module, 545, 549
components, 551-582
connection and query script, 172-175
custom error handler, 574-576
customer management module, 545, 547, 583-595
code overview, 584-587
customer form, 591-593
customer receipt page, 593-595
customer validation, 587-591
functions performed, 583
customer table, 432
database parameters, 569
entities, 730
ER model of, 733-736
general-purpose functions, 576-582
homepage, 545
Linux installation, 685
Mac OS X installation, 711
modules, 544
ordering and shipping module, 545, 549, 618-641
code overview, 618
confirmation email, 635
credit card and shipping instructions, 620-624
email receipt, 630-637
finalizing orders, 624-630
functions performed, 618
HTML receipts, 637-641
tables, 619
password management, 547
PEAR DB connection, query and results, 223
PEAR ITX template class, usage in, 551
relations in, 726-728
requirements, 542-544
script files and functions, 550
scripts, 545-551
searching and browsing module, 643-645, 648-658
tables, 643
select lists on HTML forms, 184-188
shopping cart module, 545, 548, 596-617
adding items, 609-613
code overview, 597
emptying the cart, 613
functions performed, 596
implementation, 604-617
tables, 604
updating quantities, 614-617
viewing the cart, 606-609
source code, 550
validation, 569-574
Windows installation, 695
winestore homepage, 598-604
winestoreFormTemplate class, 561-568
winestoreTemplate class, 552-561
buttons and button parameters, 560
winestore.inc (winestore database), 576, 576-582
winestore.tpl (winestore database), 552
WITH ROLLUP modifier, 495-496
write( ) function (PHP), 750
writeln( ) method (JavaScript), 311
X[ Top ]
XML
PEAR packages for, 250
report output format, using for, 425
xpdf, 424
Z[ Top ]
Zip code validation, 290-292
Zip programs, 688