Multi Tier Application Programming with PHP 1st Edition David Wall 2024 scribd download
Multi Tier Application Programming with PHP 1st Edition David Wall 2024 scribd download
com
https://ebookname.com/product/multi-tier-application-
programming-with-php-1st-edition-david-wall/
OR CLICK HERE
DOWLOAD NOW
https://ebookname.com/product/web-programming-for-business-php-object-
oriented-programming-with-oracle-1st-edition-david-paper/
ebookname.com
https://ebookname.com/product/programming-php-2nd-edition-covers-
php-5-rasmus-lerdorf/
ebookname.com
https://ebookname.com/product/air-pollution-and-turbulence-modeling-
and-applications-1st-edition-davidson-moreira/
ebookname.com
Improve Your Chess Calculation 1st Edition R.B. Ramesh
[Ramachandran Ramesh]
https://ebookname.com/product/improve-your-chess-calculation-1st-
edition-r-b-ramesh-ramachandran-ramesh/
ebookname.com
https://ebookname.com/product/world-class-applications-of-six-sigma-
real-world-examples-of-success-1st-edition-jiju-antony/
ebookname.com
https://ebookname.com/product/engineering-innovative-products-a-
practical-experience-1st-edition-roger-woods/
ebookname.com
https://ebookname.com/product/o-codigo-civil-brasileiro-em-ingles-the-
brazilian-civil-code-in-english-1a-edition-leslie-rose/
ebookname.com
The Body Keeps the Score 1st Edition Bessel Van Der Kolk
https://ebookname.com/product/the-body-keeps-the-score-1st-edition-
bessel-van-der-kolk/
ebookname.com
Building Web Apps with WordPress 1st Edition Brian
Messenlehner
https://ebookname.com/product/building-web-apps-with-wordpress-1st-
edition-brian-messenlehner/
ebookname.com
Multi-Tier Application Programming
with PHP
Practical Guide for Architects and Programmers
The Morgan Kaufmaiin Practical Guides Series
Series Editor. Michael J. Donahoo
Multi-Tier Application Programming with PHP:
Practical Guide for Architects and Programmers
David Wall
For further information on these books and for a list of forthcoming titles, please visit our
website at http://www.mkp.com/practical
Multi-Tier Application
Programming with PHP
Practical Guide for Architects
and Programmers
David Wall
_ _i®
AMSTERDAM BOSTON HEIDELBERG LONDON
NEW YORK OXFORD PARIS SAN DIEGO
: < ^ '
T CTT» rwTUTt ^^'^ FRANCISCO SINGAPORE SYDNEY TOKYO
J:ll^ri>Vl£SK Morgan Kaufmann Publishers Is an i m p r i n t of Elsevier M O R G A N K A U F M A N N PUBLISHERS
Senior Editor: Rick Adams
Publishing Services Manager: Andre Cuello
Associate Editor: Karyn Johnson
Project Manager: Kristin Macek
Design, illustration, and composition: Cepha Imaging Private Limited
Cover Design: Yvo Riezebos Design
Cover Image: Cargo containers being stacked at terminal.
© Sandra Baker/The Image Bank
Copyeditor: Graphic World Publishing Services
Proofreader: Graphic World Publishing Services
Printer: The Maple-Vail Book Manufacturing Group
Designations used by companies to distinguish their products are often claimed as trademarks or
registered trademarks. In all instances in which Morgan Kaufmann Publishers is aware of a claim,
the product names appear in initial capital or all capital letters. Readers, however, should contact
the appropriate companies for more complete information regarding trademarks and registration.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any
form or by any means—electronic, mechanical, photocopying, or otherwise—without written
permission of the publishers.
Permissions may be sought directly from Elsevier's Science & Technology Rights
Department in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, e-mail:
permissions@elsevier.com.uk. You may also complete your request on-line via the Elsevier
homepage (http://elsevier.com) by selecting "Customer Support" and then "Obtaining Permissions.'
Application Submitted
ISBN: 0-12-732350-3
Preface xiii
1 Introduction 1
1.1 Defining Multi-Tier Software Design 1
1.2 Advantages of a Multi-Tier System 2
1.2.1 Software Modularity 3
1.2.2 Reliability 4
1.2.3 Division of Responsibility and Ease of Management
1.2.4 Ease of Documentation 4
1.2.5 Security 5
1.2.6 Performance and Scalability 5
1.3 Disadvantages of a Multi-Tier System 6
1.3.1 Execution Speed 6
1.3.2 Network Latency 6
1.3.3 Security 7
1.4 Questions and Exercises 7
VII
VIII Contents
HTTP in PHP 21
3.1 Understanding HTTP 22
3.1.1 A Simple Page Request and Response 22
3.1.2 A More Complex GET Request 24
3.1.3 A POST Request 26
3.2 Working with HTTP in PHP 26
3.2.1 Accessing GET Variables 26
3.2.2 Accessing POST Variables 27
3.2.3 Accessing Various HTML Form Elements 29
3.3 Cookies 37
3.3.1 Setting Cookies 38
3.3.2 Retrieving Cookies 39
3.3.3 Deleting Cookies 40
3.4 Sessions 40
3.4.1 Preparing the PHP Server for Session Tracking 41
3.4.2 Establishing a Session 41
3.4.3 Setting a Session Variable 42
3.4.4 Retrieving a Session Variable 42
3.5 Questions and Exercises 43
Afterword 267
Index 269
This Page Intentionally Left Blank
Preface
I his book aspires to replace trust in commercial products with reliance on open-source
software and your own ingenuity.
We've all been in a situation in which a customer wants to solve some complicated
information-services problem without spending much money. Maybe the project is a one-
off demonstration that's unlikely to lead to much of a sale. Maybe it's a proof-of-concept
project that may never get real funding. Maybe, and this isn't uncommon at all, the cus-
tomer is just cheap and wants a real, highly capable, production solution for the absolute
least amount of money possible. The application typically is feature rich, with a substantial
data model backing it up. It may be something like a travel reservation system, a catalog,
a data warehouse full of scientific of business data, or, as is modeled in several chapters
of this book, an accounting system.
These are the sorts of applications for which Microsoft touts the .NET Framework
and Sun Microsystems sells Enterprise Java. Those are extraordinarily capable develop-
ment environments. They are also more or less proprietary, and dependent on expensive
software licenses.
The environment that seems to be emerging in many companies is one in which the
first budget line item to fall is the one for software licenses. That means open-source
software fits the budget, and often its capabilities stack up quite favorably against its
commercially licensed competitors. But if the motto of the open-source community is
"do it yourself," there's bound to be some professional services time required to make the
software do what's needed.
Multi-Tier Application Programming with PHP: Practical Guide for Architects and
Programmers is meant for people who find themselves—or would like to find themselves—
in the position of having to provide those professional services.
XIII
XIV Preface
Goals
Before you start designing applications, you'll need to understand what multi-tier design
is all about, and how to implement it with PHP and related technologies. You'll also need
some design guidance as to when it's appropriate to try to structure your applications
as multi-tier entities under PHP, when it's better to go for a full-blown solution under an
application server (as with Enterprise Java), and when a more traditional PHP solution
is best.
The essence of multi-tier (usually, it boils down to three-tier) application design is
the separation of the logical functions of an application into several layers:
The accessor layer (the model) manages interaction with a database management
system (DBMS). Its job is to query the database as efficiently as possible, making opti-
mum use of the available database connections and sharing database access across
multiple lower-level activities where possible. It exposes methods that represent
abstractions of what's in the database.
The business-logic layer (the controller) decides what sort of data to extract from
the database under various conditions. Further, it can process that data to yield
meaningful information. For example, the business-logic layer might be set up to
request revenue and expenditure data from the persistence layer, then process those
pieces of information and expose a method that returns a profit figure.
The presentation layer (the view) is concerned with providing an interface to the user.
It presents a user interface (in hypertext markup language [HTML], typically) that the
user can manipulate, and it formats the results of the business-logic layer's work in
an attractive way.
The advantage of designing applications this way is ease of maintenance and modification,
as well as better performance under load.
PHP has met tremendous success in the space between static Web pages (simple, not
very flexible, and hard to maintain) and three- or four-tier enterprise applications under
an application server like WebSphere or WebLogic (which are hard to learn, complicated,
expensive, and not worth the trouble for any but the largest projects). For the bulk of
network applications—which require database connectivity, interaction with a user via
forms, an ability to output HTML, and some mechanism for maintaining state in the inher-
ently stateless environment of hypertext transport protocol (HTTP)-—PHP and MySQL do
Another Random Scribd Document
with Unrelated Content
with the news of a most extraordinary indiscretion on the part of
Prince Soudaroff. He had actually said—true, it was after dinner and
in the presence of only a few intimate diplomatic friends,—but he
had said that Scythia looked to Emathia under her new ruler to
compensate her for the losses and disappointments she had
sustained in the Far East. Instantly all the people who had been
thunderstruck when the Scythian Ambassador at Czarigrad proposed
Maurice’s election nodded wisely at one another. This was the
explanation, then! No one had ever suspected Scythia of acting on
an impulse of pure philanthropy, and it was abundantly clear that
she had received ample guarantees from Prince Theophanis before
she put her interest in him to the test of publicity. When Maurice’s
supporters denied indignantly that he had given her any pledges,
they merely nodded more wisely still, and implied that the denial
raised their opinion of his political sagacity.
The most keenly amused of his critics was Prince Romanos, who
had been one of the first arrivals at the resuscitated city, carrying
one arm in a sling, but more gay and debonnaire than ever, so
bubbling over with pleasure at meeting his friends again that it
would have been sheer cruelty to refer to the circumstances in which
he had parted from them. A violent flirtation with Donna Olimpia
occupied most of his time at first, but the Princess Dowager took a
very strong view of this amusement when it came to her knowledge,
and practically forbade him her house, so that his rivals were free to
enjoy his society all day long.
“You are unfortunate in your backer,” he said one day, when
Maurice and Wylie had been discussing with considerable irritation
the latest Scythian manœuvre. “Now I cannot flatter myself that
Pannonia proposed me for any more exalted reason than to prevent
your being elected, but at least she lets me alone.”
“Probably much better for your prospects,” growled Wylie.
“But certainly. Scythia’s fussy eagerness for your success can
only do you harm, while Pannonia’s wholesome neglect will bring me
in triumphantly.”
“You seem very sure you are going to succeed,” said Maurice.
“I am; absolutely certain. I feel it here,” he struck his chest. “I
will tell you why,” he lowered his voice mysteriously; “everything has
succeeded with me lately. I am in the—what do you call it?—line of
success.”
“I can’t for the life of me see why you should succeed,” said
Wylie.
“Because I am not handicapped by the favour of Scythia, if for
no other reason. You cannot deny that Princess Theophanis was the
playmate of the Emperor’s sisters, or that the Scythian court is
showing the kindest interest in her. Now no one can say that I have
a wife at all, far less one connected in any way with royalty, so that I
stand upon my own merits—a poor foundation, perhaps, but less
slippery than the Scythian iceberg.”
Not less perturbed than Maurice and Wylie by the
unaccountable benevolence of Scythia were the former’s supporters
among the delegates, who were now beginning to pour into the city.
Most of the men who survived the fall of Hagiamavra seemed to
have contrived to get themselves elected, and they gravitated
naturally to the house (little more than a broad verandah
approached by steps and with some cupboards beneath and in the
rear), which was the headquarters of the Theophanis cause. Here
Maurice and Wylie were generally to be found, with Dr Terminoff,
and Professor Panagiotis when he could spare time from his wire-
pulling, and the delegates became accustomed after a time to see
Prince Romanos there also. This friendly association of the two
candidates, which at first revolted their sense of propriety, began to
recall the days at Hagiamavra, over which a glamour was already
tending to gather, and the delegates applied themselves to well-
meant efforts for perpetuating the happy state of things that had
reigned there, quite oblivious of the fact that an arrangement which
had not even answered particularly well temporarily might be a
disastrous failure if adopted in permanency. To their practical minds
it seemed now quite beside the question to determine which of the
candidates had the greater right on his side; the important thing was
to compose an unhappy family feud in such a way that all parties
should, if possible, be satisfied. Early one morning a number of them
invaded the verandah, and when Maurice had been established in his
chair in their midst, and coffee and cigarettes brought in, the
spokesman demanded one more assurance that he was not in any
way pledged to Scythia in the event of his being elected.
“It is not that we doubt the Prince’s word,” said the old man;
“but we desire to treat the Lord Romanos with all fairness, and we
have a word to say for him to-day.”
Prince Romanos, leaning against the wall with a cigarette in his
hand, smiled, and acknowledged the kind intention lazily.
“The Lord Romanos is the younger man, and unmarried,”
pursued the spokesman. Prince Romanos started involuntarily. “Let
him marry the sister of the Lord Mavrikios, and they two shall be
next heirs after him and his wife.”
“My sister is already betrothed, with my full consent, to the Lord
Glafko here,” said Maurice, keeping a grave face. A look of dismay
went round the assembly.
“Yet another prince!” muttered the spokesman. “There were two
kings in Sparta, but who ever heard of three?”
“I am the Prince’s servant, and desire no more,” said Wylie.
The old man’s face cleared. “But it is beneath the dignity of the
Lady Zoe to wed a servant. Will the Lord Glafko stand in the way of
this excellent arrangement?”
“Certainly not, if the Lady Zoe prefers it,” said Wylie heartily.
“Shall I go and tell her so? But I suppose I am not the proper
person. Would you like to represent it to her?” he asked the
spokesman, who hesitated, but recovered himself quickly.
“Nay, lord; how could I put the thing as it should be put? Let
the Lord Romanos himself ask her, for who should plead his cause
better than he himself?”
Again the rest applauded, and Prince Romanos seemed to shake
off a certain hesitation, and looked round laughing.
“I take you all to witness that I am sent on this errand without
my consent. One does not go by choice to propose to another man’s
bride. But if I have your moral support——? The ladies are at home,
Prince?”
He disappeared indoors, and the assembly awaited his return
breathlessly. When he came back, he was still laughing.
“The Lady Zoe says she would not marry me if I were the only
man in the world,” he said. “Well, you will at least bear witness that
it was not I who refused, but she.”
The delegates assented sadly, and the spokesman propounded,
without enthusiasm, an alternative plan.
“Let the Prince and his wife adopt the Lord Romanos as their
son.” Maurice winced painfully. “Then he may take part in the
government while they live, and reign after them.”
“The idea is not a bad one,” murmured Professor Panagiotis,
who had come in almost unnoticed, and taken his place beside
Maurice. But Prince Romanos laughed boisterously.
“My dear good friends, I hope Prince Theophanis will live a
hundred years, but I do not propose to be kept out of my
inheritance as long as that. No, what I want is to be Prince of
Emathia at once. He wants the same. Therefore we must fight it
out.”
The assembly subsided into silence, and suggested no more
schemes that day. But in the evening, when the delegates were
gone, and Dr Terminoff had joined the party on the verandah, the
Professor recurred to the second one.
“I could wish that Prince Christodoridi were willing to waive his
present claims in view of recognition as hereditary prince, and
eventual successor,” he said.
“No doubt you could,” said Prince Romanos. “But what have you
ever seen in me, my dear Professor, to make you imagine me a
model of patient unselfishness?”
“Nothing, I confess it,” said the Professor emphatically. “But I
should like to see our forces united. As it is, Scythia and Pannonia
have every chance of ruining our hopes, and they are already taking
advantage of it. Nilischeff is proclaiming loudly that Prince
Theophanis is the mere instrument of Scythia, and he influences
many votes.”
“And you have already lost so many that if he votes for me, I
shall be elected?” said Prince Romanos. “Come, this cheering
prophecy gives me courage to make a modest proposal of my own.
Let us face the situation without disguise. Emathia is Slav, is Greek.
We should probably disagree about the proportions, therefore I will
not go into details. Rightly or wrongly, the Slavs entertain a
preference for you, my friend,” to Maurice, “the Greeks for me. I
speak roughly, of course, but that is the general idea. The Slavs
occupy the high ground in the interior—speaking roughly again—the
Greeks the low country nearer the sea. Therefore Emathia is capable
of division into two provinces, the population of one predominantly
Greek, of the other predominantly Slav. Let us determine to divide
her thus. Whichever of us succeeds in the election will be Prince of
Emathia, and mouthpiece of the Powers, but he cannot dispense
with the other. I have no liking for your rugged hillmen, you have no
sympathy with my brilliant elusive Greeks. Therefore, if I become
Prince, I will place you in charge of the Slav province and the
scattered Slavs in the low country. If you succeed, give me the care
of the lower province and the Greeks dwelling in the upper.”
“But you are merely perpetuating the racial cleavage which has
done all the mischief!” cried Maurice, as Prince Romanos stopped
short with gleaming eyes.
“I think not. There would be one army, one judicial system.
Colonel Wylie will give us the benefit of his Indian experience in
organising them. The plan could not of course be worked unless we
were bound by the closest friendship, but we have been through
much together——”
“The plan would checkmate Scythia,” said the Professor sharply.
“I could not suggest it to any one possessing less nobility of
character than Prince Theophanis,” said Prince Romanos, not without
a hint of malice. “His zeal is so entirely for the sake of Emathia that I
can do so without being misunderstood.”
“It sounds excellent now, when we expect to succeed,” said
Wylie. “The question is, how it will look to us if we fail. What do you
say, Prince?”
“The Prince will say that if it is for the good of Emathia, he will
agree to it,” said Prince Romanos boldly.
“Very likely,” grumbled Wylie. “I am not the person to judge. It
takes a poet to think of a thing of this kind——”
“And a fool to agree to it?” said Maurice. “But if it will give the
strength we need for the struggle against disruption? After all, it
would only be doing on a large scale what we tried on a small one at
Hagiamavra.”
“Where it was not exactly successful,” said Wylie. “Oh, I know
it’s ideally desirable, but these things want ideal people to carry
them out.”
“There is no idea of binding ourselves by a hard and fast
agreement,” said Maurice, as Prince Romanos laughed and bowed.
“It must be understood that the thing is purely tentative. If the man
in possession finds that the other is not working loyally with him, or
if the other—the under dog—finds he is thwarted in his pet schemes
without good cause, either may terminate it. We must have
arrangements for talking things over thoroughly together at frequent
intervals, of course.”
“Then you agree?” cried Prince Romanos joyfully. “Welcome,
then, my colleague! You observe that I at once claim for myself the
part of upper dog—what is that you say, top dog?—and proceed to
constitute my cabinet. Prince Theophanis my Prime Minister, my
Protector of Slavs, my second self; Colonel Wylie my War Minister;
Professor Panagiotis my Foreign Secretary, Press Censor, Director of
Public Education and of my political conscience; Dr Terminoff,
Minister of Public Health. This day week the Prince of Emathia will
claim your services, gentlemen.”
CHAPTER XXVI.
PAYING THE BILL.
THE END.
TRANSCRIBER’S NOTES.
Sydney C. Grier was the pseudonym of Hilda Caroline Gregg.
This book is part of the author’s “Balkan Series II.” The series,
in order, being: The Heir, The Heritage, and The Prize.
Alterations to the text:
Note: minor spelling and hyphenization inconsistencies (e.g.
thunderstruck/thunder-struck, rank-and-file/rank and file, etc.) have
been preserved.
[Title Page]
Add brief note indicating this novel’s position in the series. See
above.
[Chapter VI]
Change “You musn’t be so doleful” to mustn’t.
[Chapter IX]
“detention in the court yard” to courtyard.
[Chapter XIV]
“it may be necessary any day to to get all our forces together”
delete one to.
[Chapter XVI]
“there was no gurantee of even temporary safety” to guarantee.
[Chapter XX]
“for the poor starving peeple around” to people.
[Chapter XXI]
“Wyllie transferred his whole force” to Wylie.
[End of Text]
*** END OF THE PROJECT GUTENBERG EBOOK THE HERITAGE ***
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com