Later today, I’m going to a “30th on 30th” event where my friends and I will visit several restaurants and bars to sample some of their food and drinks. There’s a blog that has posted some items that will be served, but I have no clue where they are relative to 30th Street. I don’t know if they’re all close to each other or far apart, and since I’m the contact person for people meeting the group there, I thought I should do some research to map out the places. Since we might do this again, and since many places participate regularly, I thought it’d be useful to work on a mashup to at minimum show the places on a map. I was going to print it out, but with this method everyone can pull it up on their phone. So, this will document part of my work.
I’ve been programming with the Yii framework, and I like how it simplified a lot of tasks like the built in entry forms from the CRUD. To get started, I’m going to build the database now. Since my new Macbook Air isn’t fully set up yet with all my apps, and I don’t have my work Macbook Pro here, I’ll do this with my PC. Eek! So, my tools will be Netbeans 7.0 and MySQL Workbench.
“places” table to store the name, address of each restaurant/bar, and latitude/longitude for mapping
“special” table to store the date and what’s being offered.
foreign key linking special.place_id to places.place_id
Yii Setup – using yiic to create basic web app files and directories
I’m programming in XAMPP, which is stored at C:\xampp. To set up a basic Yii setup, you need to run “yiic”. I’m more of a unix person, so it was a little trickier to do this on my PC. Well, it wasn’t that hard. Here’s what I did:
c:\xampp\php\php.exe framework\yiic webapp 30th
That will prompt you to confirm that you want to create a “Web application”. I typed “Yes”. It’ll spew out some log info about what files and directories get created. At the end, you should get a message telling you that your application was created successfully.
Yii Setup – using gii to create models, controllers, crud
With the database and web app files created, it’s time to use ‘gii’ to automate the creation of models, controllers and crud pieces. I had to check the Yii site to find an example of the order in which these are created. Here’s my order, based on this article, http://www.larryullman.com/2009/11/07/creating-models-views-and-controllers-in-yii-2/:
model generator (table names: place, special)
crud generator (Model Class: Place, Special)
note … this will automatically create the controllers too =)
So far, so good. Nothing has really presented itself as an obstacle, so now it’s time to use the crud forms to enter data. My dev virtualhost is called “30th”, so I can just go to http://30th/place to see the view for the “places” in the database. There’s nothing here now, so I’m going to click on “create”, which will go to http://30th/place/create. It didn’t quite take me there automatically. I had to enter the admin info first …
So, now I’m going to do the boring task of getting the address data for each participating place.
Quick note … since all the places are in San Diego, I altered the database to use city:San Diego and state:CA as the default into. I also recreated the model and crud generators for the “place” table.