Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying CakePHP 2 Application Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
CakePHP 2 Application Cookbook

CakePHP 2 Application Cookbook - Third Edition

By : Watts
4.2 (6)
close
close
CakePHP 2 Application Cookbook

CakePHP 2 Application Cookbook

4.2 (6)
By: Watts

Overview of this book

If you are a CakePHP developer looking to ease the burden of development, then this book is for you. As a headfirst dive into the framework, this collection of recipes will help you get the most out of CakePHP, and get your applications baked in no time. Even if you're not familiar with the framework, we'll take you from basic CRUD building to useful solutions that will aid in getting the job done quickly and efficiently.
Table of Contents (14 chapters)
close
close
13
Index

Building an XML view


You may want to return your data at some point in a format other than HTML. For this, CakePHP comes with the ability to use data views. By default, the framework includes data view for XML, JSON, and RSS, but you can also build your own, handling content as required by your output format.

In this recipe, we'll use XmlView to generate an XML output of some records from a model.

Getting ready

We first need a table of data to work with. Create a table named news using the following SQL statement:

CREATE TABLE news (
  id INT NOT NULL AUTO_INCREMENT,
  title VARCHAR(50),
  summary TEXT,
  created DATETIME,
  PRIMARY KEY(id)
);

Then, run the following SQL statement to insert some news into our table:

INSERT INTO news (title, summary, created)
VALUES
('CakePHP on top', 'Nominated as the best framework!', NOW()),
('Facebook buys Twitter', 'Mark becomes the first zillionaire', NOW()),
('The Larry peak', 'Founder of CakePHP admits beer helped his code', NOW());

Before we start, we'll...

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
CakePHP 2 Application Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon