Feeds

Put some MVC in your PHP

Trial by separation

High performance access to file storage

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.®

Combat fraud and increase customer satisfaction

More from The Register

next story
This time it's 'Personal': new Office 365 sub covers just two devices
Redmond also brings Office into Google's back yard
Batten down the hatches, Ubuntu 14.04 LTS due in TWO DAYS
Admins dab straining server brows in advance of Trusty Tahr's long-term support landing
Inside the Hekaton: SQL Server 2014's database engine deconstructed
Nadella's database sqares the circle of cheap memory vs speed
Microsoft lobs pre-release Windows Phone 8.1 at devs who dare
App makers can load it before anyone else, but if they do they're stuck with it
Oh no, Joe: WinPhone users already griping over 8.1 mega-update
Hang on. Which bit of Developer Preview don't you understand?
Half of Twitter's 'active users' are SILENT STALKERS
Nearly 50% have NEVER tweeted a word
Internet-of-stuff startup dumps NoSQL for ... SQL?
NoSQL taste great at first but lacks proper nutrients, says startup cloud whiz
Windows 8.1, which you probably haven't upgraded to yet, ALREADY OBSOLETE
Pre-Update versions of new Windows version will no longer support patches
IRS boss on XP migration: 'Classic fix the airplane while you're flying it attempt'
Plus: Condoleezza Rice at Dropbox 'maybe she can find ... weapons of mass destruction'
prev story

Whitepapers

Top three mobile application threats
Learn about three of the top mobile application security threats facing businesses today and recommendations on how to mitigate the risk.
Combat fraud and increase customer satisfaction
Based on their experience using HP ArcSight Enterprise Security Manager for IT security operations, Finansbank moved to HP ArcSight ESM for fraud management.
The benefits of software based PBX
Why you should break free from your proprietary PBX and how to leverage your existing server hardware.
Five 3D headsets to be won!
We were so impressed by the Durovis Dive headset we’ve asked the company to give some away to Reg readers.
SANS - Survey on application security programs
In this whitepaper learn about the state of application security programs and practices of 488 surveyed respondents, and discover how mature and effective these programs are.