Prev | Current Page 136 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

>
(annotation) <#2 The result key in the returned array is used for error reporting.>
(annotation) <#3 Turn off the view renderer.>
Encoding to JSON is taken care of by the Zend_Json component. There are two static functions, encode()
and decode() available that will use the PHP JSON extension if available, otherwise will use a PHP
implementation. Obviously, the PHP JSON extension is faster, but it is useful to know that the class will work
even if it isn??™t available.
The rest of the code in feedbackAction() is standard Zend_Framework code that updates the counts of the
database fields helpful_yes and helpful_total within the reviews table for the particular view in question. In this
case, we construct the SQL directly and execute it using the query() function of the Zend_Db object. Note
that as we use the review id from the user within the SQL directly, the cast to an integer is vital to ensure that
we don??™t accidentally introduce an SQL injection vulnerability.
4.6 Summary
Within this chapter we have looked at what Ajax is and where it fits within a Zend_Framework application.
While it is possible to hand craft all the Ajax code required, it is easier to use one of the many libraries
Licensed to Menshu You
Please post comments or corrections to the Author Online forum at
http://www.


Pages:
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
kasyno kino azjatyckie bwin out of home advertising Bukmacher pinacle