Pragmatism in the real world

Some notes on SQL Server blobs with sqlsrv

I recently updated my use of SQL Server with Zend_Db_Adapter_Sqlsrv to use UTF-8 throughout. This turned out to be easy enough: Use ntext, nvarchar types in the database add: resources.db.params.driver_options.CharacterSet = "UTF-8" to your application.ini I subsequently noticed a problem with storing binary data to a varbinary(max) field. The error was: An error occurred translating string for input param 2 to UCS-2: No mapping for the Unicode character exists in the target multi-byte code page.… continue reading.

Ralph Schindler: Composite Rowsets For Many-To-Many Relationships Via Zend_Db_Table

Ralph has just posted an excellent article on how many to many relationships work with Zend_Db_Table: Basically, I’ve created a single class that effectively take the place of Zend_Db_Table_Row::findManyToManyRowset() for the purposes of creating an iterable rowset that allows access to both the target many-to-many rowset as well as the junction rowset. This solution is called a Composite Rowset. In this solution, both rowsets (iterators) are kept in sync with one another. This proves to… continue reading.

Validating UK Postcodes

I'm sure everyone else already knows this, but I've recently discovered that Zend_Validate_PostCode doesn't work with UK postcodes unless you first remove the space between the first and second parts. This is due to a bug in the underlying regular expresssions that are provided by CLDR. It's easy enough to add a filter to remove the space, but I'm a little worried that when (and if) it gets fixed, will the fixed version Zend_Validate_PostCode then… continue reading.

Validating dates

I discovered recently that Zend Framework 1's Zend_Date has two operating modes when it comes to format specifiers: iso and php, where iso is the default. When using Zend_Validate_Date in forms, I like to use the php format specifiers as they are what I'm used to and so can easily know what they mean when reviewing code that I wrote months ago. My code looks something like this: $subForm->addElement('text', 'start_date', array( 'filters' => array('StringTrim', 'StripTags'),… continue reading.

I'm speaking at PHPBenelux Conference 2011

I'm delighted to be able to announce that I'm speaking at the PHPBenelux Conference on 28 & 29 January 2011 in Antwerp, Belgium. This is a community run conference organised by the PHPBenelux user group and given the list of speakers, I'm expecting to learn a lot. The full list of talks is on their website and shows that this is going to be a great conference. I'll be giving a talk that will introduce… continue reading.

SqlSrv v2 and long field names

A good proportion of the projects my company undertakes end up on Windows servers with IIS and SQL Server and hence we use the SqlSrv PHP extension from Microsoft. We don't host any of these projects ourselves and leave it up to the client's IT department. This is the main reason that we use a database abstraction layer, Zend_Db, in our case as we can swap the underlying database out with less hassle. A couple… continue reading.

PHPNW10 Conference

The PHPNW Conference is an annual conference held in Manchester, now in its 3rd year and again I was invited to speak. The organisation of PHPNW was top-notch as usual with everything running smoothly from my point of view. I'm sure there were a few hectic moments for the organisers though :) The day started with Lorna's keynote on how to improve your skill set as a team. This was a great talk which sparked… continue reading.

A form in your layout

I recently received an email asking for my advice about how to handle a form that appears on every page. I want to add a newsletter sign up box to layout.phtml so it will appear on every page. The layout->content() comes from several different action controllers… So how do I handle the newsletter sign up? I thought that the answer is long-winded enough to be worth writing a blog post about. One way to do… continue reading.

OS X Tips and Tricks for Snow Leopard

Following some discussions with friends who've recently started using OS X, I thought I'd note down some tips and tricks that I've learnt since I moved to Mac. This is in no particular order as it's taken from IRC logs of conversations I've had :) Basics There's one menu bar for all application Closing the last window doesn't exit the application. Use cmd+q or the Quit menu item on the "application name" menu. System Preferences… continue reading.

Devzone article on Zend_Config

Vikram Vaswani has written an article on Manipulating Configuration Data with Zend_Config. Zend_Config seemed to meet my needs, so I played with it a little and then deployed it in a couple of projects. It did everything I needed it to, and was easy to integrate with both framework and non-framework PHP projects. It also has a couple of neat features, such as the ability to merge multiple configurations together. Keep reading and I'll give… continue reading.