Book Image

Yii Project Blueprints

By : Charles R. Portwood ll
Book Image

Yii Project Blueprints

By: Charles R. Portwood ll

Overview of this book

Table of Contents (15 chapters)
Yii Project Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Importing the data feed


Before creating the frontend controllers to display our data, we need to create a tool to import our data feed. To create this tool, we create a class in our commands directory that extends CConsoleCommand; this will enable us to import data from the command line and automate it if we so choose.

To begin, we need to create a new class called ImportLocationsCommand inside of our commands directory at /protected that extends CConsoleCommand. The filename inside the commands directory should be ImportLocationscommand.php:

<?php
class ImportLocationsCommand extends CConsoleCommand {}

Next, we add a method to handle the retrieval of the data we want to import. To provide the greatest amount of flexibility, we create two methods: the first will fetch the data from our external data source and the second will actually import the data into our database.

In a real-world application, the first method that we build might fetch the data from a web resource via CURL. Alternatively...