Entries written in April 2008

Today, let’s take a look at Zend_Db. Zend_Db implements a Table Data Gateway, in which the object is considered to be extended to have the properties of a table, as opposed to a Object Relational Model (ORM) / Data Access Object (DAO) where the object is considered to be a representation of the database object. Philosophy aside, it’s a great tool, and we’re mostly interested in how to use it. It is worth noting that you can use Zend Framework along with the excellent Doctrine ORM… and the syntax is even pretty similar.

The general procedure when setting up Zend_Db is to create a bunch of objects that extend Zend_Db_Table_Abstract. When defining an object, you can define what table it connects to, what the primary key is, and any foreign keys that relate to it. Upon instantiating the object in your code, you can use it to build queries against it’s related table, which returns a collection of row sets for direct use in your applications. Today’s tutorial assumes that you’re very comfortable with looping and other control structures in PHP.

Continue Reading »

Yesterday we left off with a basic folder structure in a Subversion repository, including the Zend Framework libs. It isn’t really much to look at, and it just doesn’t do anything. Not impressive. Let’s fix that.

Today we’ll be covering the front controller and some basic modules and actions. You still won’t need a database at this point, but you will need to have Apache configured correctly. You’ll also want to have the Zend Framework Reference Guide within easy reach.

Before we get started, make sure that your Apache configuration

Continue Reading »

Over the next few days, I’ll be covering how to set up your first Zend Framework application using PHP and MySQL.

First, some requirements. You should be comfortable on the command line or with your Subversion client. I’m writing from the point of view of someone who codes on a Linux or Mac machine using vim. You will need to have PHP 5 installed on your server — this will not work unless you do. Second, I would recommend getting a VPS from a host like Futurehosting — for $20/mo, you get root access to your own machine, you can host as many sites or servers and have as many domain names as you want, and you get 350gb a month in transfer — I don’t think I’ve used 1gb of transfer ever, and I do a ton of work with the server. I also Also, we’re going to assume you have access to a Subversion server. That’s just good practice, folks. Subversion hosts are very cheap — I usually use CVSDude.

Today we’re going to cover the folder structure, getting things into subversion, and locating the different files. Tuesday, we’ll cover the bootstrap and getting your index module and error module to show up. Wednesday, we’ll cover Zend_Db_Table_Abstract, Thursday we’ll cover Zend_Form, and Friday we’ll put it all together to get a user registration and login working.

Disclaimer: I’m by no means a whiz kid with Zend Framework. ZF is unique among frameworks in that it gives you a toolset but does not enforce any conventions. The conventions I’m giving here are *my* conventions and may have nothing to do with the way you want to code.

Let’s dive right in.

Continue Reading »

Written April 26, 2008 in meta, puppy

Eowyn and I traveled to the Texas A&M Small Animal Hospital on Tuesday the 23rd to get her hips evaluated for surgery.

Continue Reading »

Written April 23, 2008 in meta, puppy

Hey, y’all. You might’ve noticed the addition of ads to the non-RSS feed website. I’ve added them because I need some cash, from any source available. Eowyn needs surgery on her hips, and I’m having a few health problems of my own that are sucking up the money I would’ve …

Continue Reading »

Written April 19, 2008 in webdev, zend framework

I’ve been doing a lot of work with Zend Framework the past few days. One of the things that’s been bugging me is how much code I have in my controllers to save data. The validation and filtering is handled by the Zend_Form object, but the forms don’t always match the models as far as fieldnames and other information, so I don’t just want to throw a form result set at a Zend_Db_Table_Row and let it figure things out.

Result: I taught my forms to know how to fill and save themselves. They use the model layer to accomplish this, but work mostly by extending the normal Zend_Form with a ‘populate’ and a ’save’ method. The populate method can be static. It takes a primary key and returns an array that can be used to populate the form. The save method is not static, and depends on the form already being populated and having been validated.

As a quick disclaimer, I by no means would say that this is the best practice for this kind of thing … and this code is quickly hacked up edited code that I put together from what I’m really doing. No guarantees that it works … however, the theory works for me!

Continue Reading »

Written April 18, 2008 in linux, mysql, webdev

Some updates: Matthew Aslett, Marten Micoks on jcole.us: [ 1 ] Slashdot: [ 1, 2 ], Lukas Smith’s reaction.

Well, I guess it’s time to learn Postgres again. Sun Microsystems bought MySQL AB (The makers of the MySQL Database) in February, and now they’ve announced that …

Continue Reading »

Written April 16, 2008 in linux, sysadmin

We’ve had problems recently with our Dell 1650s at work. After five or six years of steady service, in the past three weeks we’ve had two bad fans on two separate machines, another machine has a voltage wobbly on it’s drive backplane, and another one failed with a rather dramatic …

Continue Reading »

Written April 13, 2008 in apple

Sebastiaan de With covers the encroachment of Helvetica into Mac OSX UI Design. Via Daring Fireball.

With the most recent re-do of my blog, I was very careful with the typography. Essentially, the entire interface is typography — there are no images. No backgrounds, no toothpicks, nothing. White space …

Continue Reading »