Feeds

Put some MVC in your PHP

Trial by separation

Protecting against web application threats using SSL

Assign the row column values to the Zend_View instance. The variables assigned to the Zend_View object become the properties of the Zend_View object.

$view->id = $_POST['id'];
$view->journal = $rowset[0]["JOURNAL"];
$view->publisher = $rowset[0]["PUBLISHER"];
$view->edition = $rowset[0]["EDITION"];
$view->title = $rowset[0]["TITLE"];
$view->author = $rowset[0]["AUTHOR"];

Create a view script, resultView.php, associated with the Zend_View object. The view script will run in the scope of the Zend_View object. References to $this in the view script are references to the Zend_View object. Create a table header and add values to the table using the Zend_View properties assigned in the action controller. In the selectAction function render the resultView.php script.

echo $view->render('resultView.php');

Invoke the selectView.php view script with the URL http://localhost/views/selectView.php. Specify the catalog ID for the row that is to be retrieved and click select.

Selecting a database table row

Selecting a database table row

The row corresponding to the specified catalog ID will be retrieved and the results displayed.

Update a Row

Next, update a catalog table row using the Zend Framework. Create an associative array, $data, of column names and values for the row to be updated. Create a SQL expression specifying the WHERE clause for the ID of the row to be updated.

$where[] = "ID ="."'".$_POST['id']."'";

Update the database table using the update() method.

$n = $db->update('Catalog', $data, $where); 

Invoke the updateView.php script with URL http://localhost/views/updateView.php. Specify the catalog ID of the row to be updated and the column values to be updated and click on update.

Updating database table

Updating database table

A table row may be deleted using the delete() function.

MVC has a proven track record in simplifying the development and on-going maintenance of applications. Using Zend and the methodology I have outlined, you can now take advantage of MVC to simplify your work with PHP applications.®

The next step in data security

More from The Register

next story
New 'Cosmos' browser surfs the net by TXT alone
No data plan? No WiFi? No worries ... except sluggish download speed
'Windows 9' LEAK: Microsoft's playing catchup with Linux
Multiple desktops and live tiles in restored Start button star in new vids
iOS 8 release: WebGL now runs everywhere. Hurrah for 3D graphics!
HTML 5's pretty neat ... when your browser supports it
Mathematica hits the Web
Wolfram embraces the cloud, promies private cloud cut of its number-cruncher
Google extends app refund window to two hours
You now have 120 minutes to finish that game instead of 15
Intel: Hey, enterprises, drop everything and DO HADOOP
Big Data analytics projected to run on more servers than any other app
Mozilla shutters Labs, tells nobody it's been dead for five months
Staffer's blog reveals all as projects languish on GitHub
SUSE Linux owner Attachmate gobbled by Micro Focus for $2.3bn
Merger will lead to mainframe and COBOL powerhouse
prev story

Whitepapers

Providing a secure and efficient Helpdesk
A single remote control platform for user support is be key to providing an efficient helpdesk. Retain full control over the way in which screen and keystroke data is transmitted.
WIN a very cool portable ZX Spectrum
Win a one-off portable Spectrum built by legendary hardware hacker Ben Heck
Saudi Petroleum chooses Tegile storage solution
A storage solution that addresses company growth and performance for business-critical applications of caseware archive and search along with other key operational systems.
Protecting users from Firesheep and other Sidejacking attacks with SSL
Discussing the vulnerabilities inherent in Wi-Fi networks, and how using TLS/SSL for your entire site will assure security.
Security for virtualized datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.