Download Zend Enterprise PHP Patterns

Transcript
C H A P T E R 5 N A S Y N C H R O N O U S O P E R A T I O N S W I T H P H P
eb$ fk^[e`89,%
w
pdnksjasAt_alpekj$JkFk^E@lnkre`a`%7
y
mqaqa9jasVaj`=LE[Mqaqa$oahb66MQAQA[DKOP%7
eb$ mqaqa):hkcej$oahb66MQAQA[L=OOS@%%
w
pdnksjasAt_alpekj$?kqh`jkphkcejpkFk^Mqaqa%7
y
fk^9 mqaqa):capFk^$ fk^[e`%7
eb$$ fk^ejop]j_akbVaj`=LE[Fk^%%
w
pdnksjasAt_alpekj$Ejr]he`Fk^E@%7
y
kqplqp9 fk^):capKqplqp$%7
]josan9oq^opn$ kqplqp(opnlko$ kqplqp(=JOSAN[OP=NP%'
opnhaj$=JOSAN[OP=NP%%7
pdeo):reas):]josan9 ]josan7
y
Looking at the Listing 5-8, again we are using the Vaj`=LE[Mqaqa66capFk^$% method to
retrieve an instance of Vaj`=LE[Fk^ representing the job referenced by the provided job
ID. However, instead of using the Vaj`=LE[Fk^66capFk^Op]pqo$% action we call the Vaj`=LE[
Fk^66capKqplqp$% method to retrieve the output of the request.
This is where things get a bit interesting, because if you recall from the original jobs
we created using the Job Queue earlier in the chapter, the output of our job (including
the Fibonacci sequence answer) was meant to be read from the browser by a person, and
it included some basic HTML for formatting. Since we are using the exact same script
for this example, how exactly are we to retrieve the answer from the job without going
through the hassle of parsing the HTML content? The answer is simple: we simply provide two versions of the output for each job. The first version is exactly as we have seen
before (human-readable HTML) so that it can be examined from the web interface. However, the second version should be machine-readable so your web server PHP instances
can retrieve the output and extract the output easily.
Download at WoWeBook.Com
119