Its very sweet and not very spicy because I (predictably) didn’t check I had everything I needed so I had to improvise wildly – and the missing ingredients sadly were the ginger and the pepper. Still, Its very edible and I can see this going with cold turkey very nicely on boxing day. I’m also planning some apple-something (apple jelly perhaps?) since I have a few apples that need something doing with them:
Girl Geek Dinner Next Week
I often get asked why we don’t allow men at these events – well of course we do. Men can attend but only when they are invited by one of the attending girl geeks (maximum one man each please, ladies!) – meaning we can have men who are likely to contribute to the event but not be invaded if we don’t want to be. If you’re a guy and looking to go, find a girl geek and ask nicely :)
I’ll definitely be at this event – I look forward to seeing some others. I had a great time last time – so go and buy a ticket (cheap night out at £15!) and I’ll see you there!
PHPNW Post-match Analysis
On a personal level, I met up with lots of friends and also made several new ones – one of the best things about the conference for me was being able to meet “in real life” the friends I’ve made online, either on IRC or through my site or the phpwomen site. There were people there that I’ve met through my work and through attending other tech events – and to be able to shake hands and chat in person was great.
We also had a phpwomen stand at the event – which generated quite a bit of interest. For the record, we counted around 15 women in the 174 attendees, which is actually quite a lot – or rather, its more than usual – and it was great to see it. Also there were 2 female speakers out of 16 which was accidental but is also quite a good ratio so I’ll mention it (hi Steph, hi Zoe!)
All in all, it was a pretty stunning first conference – I’d like to personally thank Jeremy and the people from his family and company that he dragged in to help, and Jenny who also did a great job. The speakers were ace and the helpers on the day were also really excellent. The main sponsors were my employers, Ibuildings and it was great to have them around for this – and of course to catch up with my colleagues!
Speaking at “Beauty and the Geek”
PHP North West Conference in Manchester – Next Week!
We’ve got socials happening right over the weekend – with a pre-conference social on Friday night for people to meet up, catch up, and generally hang out (and drink), the weekend will get off to a good start. Saturday is the main conference event, ticket price includes full access to the event, a year’s subscription to php|architect magazine (in print as well as digital format), lunch, and access to the evening party with yet more food (hotpot, since we’re in the north!), and of course a selection of drinks.
For those coming from further afield, there is plenty to do in Manchester over the weekend. The conference itself is very central, so you have easy access to the entertainments of the city centre. The shopping is excellent in the city centre and for those who prefer a geekier pastime, entry to the Museum of Science and Industry is free and it is open 7 days a week.
I know there are plenty of people going and I’m really looking forward to it – to catching up with old friends (and colleagues, I don’t see them very often!), to making new ones, to hearing the talks that will be going on, and of course to a few drinks and a good time. Hope to see you there :)
Blanket for Christmas
The spaces are the squares I haven’t made yet … I need to get a move on!
Leeds Girl Geek Dinner – December 3rd
The rules of the girl geek dinners is that any geeky girls can go – and not just tapping-into-a-black-screen-in-a-darkened-room geek girls, there is no minimum requirement! Guys are also welcome but they must be there as the invited guest of one of the geeks. I’m open to persuasion if anyone would like to attend as my guest – and for the girls, I’ll see you there :)
My PHPWomen Interview on Sun’s SDN Podcast
Locale-Sensitive Dates in PHP
In particular I needed dates like “Donderdag 23 Oktober”, and I was sure PHP should know how to do this without me creating arrays for days of the week and months of the year. With some help from my friend (thanks Derick) I discovered that there is a date function in PHP that takes into account the locale of the script, called strftime. The machine needs to have the locale already installed, then you can just do:
setlocale(LC_TIME, 'nl_NL.UTF-8');
return ucwords(strftime('%A %e %B',$publish_date));
Setlocale() will return false if the language isn’t available on the host system, so its possible to check and maybe try a few likely ones or let the user know. This was useful to me and will work for other languages too – you just need the locale installed and then set with setlocale.
Introduction to Zend_Db
Modelling Tables
Zend_Db_Table is a class that represents a table. You instantiate one of these and call query functions against it. The actual code for my classes is really minimal, here’s an example:
class UserTable extends Zend_Db_Table
{
protected $_name = 'users';
protected $_rowClass = 'User';
}
The two properties that I’m setting here are all I use for basic tables. $_name tells Zend Framework which database table to use. $_rowClass tells it which class it should instantiate for the results from your select query. By default you’ll get Zend_Db_Table_Row objects but you can have it use any object which extends this class instead.
Getting Results
To get results from a table, you instantiate the relevant table class, and then fetch some results. You can restrict the results you get but Zend_Db_Select is a whole other kettle of fish that perhaps I’ll post about some other day. So a controller action might look something like this:
function viewAction()
{
$users = new UserTable();
$user_list = $users->fetchAll();
}
The $user_list variable will then hold an instance of Zend_Db_Rowset.
Working with Rowsets
The rowsets are iterators, you can loop over them and they will return objects which represent the rows in the resultset of the query. By default these are objects of type Zend_Db_Table_Row but if you set the table object’s rowClass, either in the object declaration or by calling setRowClass() before you fetch the results, then you can have any class which extends Zend_Db_Table_Row used. Its pretty common to pass the rowset straight to the view and iterate over it there – you can put any functionality you need for this object into the class you use. Let’s look at my user class for this example.
The Row Class
class User extends Zend_Db_Table_Row
{
public function getName()
{
return $this->first_name . ' '.$this->last_name;
}
public function getProfileUrl()
{
return '/users/profile/id/' . $this->id;
}
}
These are overly simple examples, but giving this kind of functionality to the user model allows it to be re-used any place you need it. I’ve also found it useful to have an intermediate table row class that contains functionality that will be used by data from more than one table – for example for formatting dates in a consistent manner.
Zend Framework and Models
This is a pretty simple overview but it took me a while to get to this point – the framework does have documentation but its quite case-specific and doesn’t really show how it ties together. Now I understand these classes and their relationships, my development project is going a lot more smoothly.