LAMP development on OSX
Posted by aubrey in Coding and Development, Opinion on August 3rd, 2009
I recently acquired myself a 13″ Macbook Pro, one of those new shiny unibody ones, which I now use as my primary work and freelance machine. I used to run Ubuntu on my laptop to ease freelance web development that I do with Zend Framework and Wordpress etc. Mostly PHP type work.
With the Mac comes a whole host of new issues to get things going, where the more hardcore Mac fundi will install things like DarwinPorts or Fink or some such. Previously I had fink installed, and never really found that I absolutely *required* it, so this time around I’m not installing anything like DarwinPorts of Fink.
However, the underlying components to do LAMP-type development are all open-source and free, and the nice folks at MAMP put together a stellar package to ease the pain. The MAMP installer gives you everything you need, to get local web development going on a Mac. It includes Apache 2.x, Mysql 5.x, PHP 4 and PHP 5, Postfix for mail delivery, and if you’re OK with paying $$$ for MAMP Pro, you’ll get virtual hosts, PHPMyadmin, Dynamic DNS support and a whole host more features. MAMP Pro is available for a 14-day trial as well.
In summary, MAMP is a one-click-to-download one-stop app for everything you need to run a fully functional local web development setup, for all values where “P=PHP”. Perl and Python support inside MAMP is not there, for those you’ll likely need to do some hacking around, but I’m sure it’s possible. Oh, there’s one thing MAMP doesn’t give you, and that’s naturally an editing environment for your projects. IDEs for [L|W|M]AMP development is a personal choice, some people prefer gvim, others use bbedit, or textmate, or Eclipse PDT. I still use the Zend IDE, as it has nice built-in support for Zend Framework, and I’ve been testing out the beta version of the 7.0.x version, and so far it looks very good.
Blog update
Ai, so I’ve not updated this blog for many moons. Yes, I’ve been lazy, and I’ve kind of been keeping busy writing twice a week (mostly, twice a week…) for The Incredible Blog, so my blog’s been taking a backseat.
I’ve always threatened myself that one day when I have a portable-enough laptop, I’ll be *that* guy that goes to sit in a coffee shop, sips a Latte while churning out a blog post or something. Well, I traded in my ugly 15″ HP work-laptop for a new 13″ Macbook Pro, which at some point in the future I will fully own. So, now I’ve got the “portable enough” laptop part done, and hell, it’s pretty enough, so now I just need to find that (a) time, and (b) motivation and (c) coffee shop, and (d) topic to write a blog post. Or ten. I really don’t want to become a “I had Marmite toast for breakfast” blogger, I’d rather write about thing topical and interesting and about things that I love. That’s what this new Docile Tree home was going to be, so, look forward to more Linux, Mac, gaming, development, movie, gadget, techie and geeky blog posts in the near future.
I also decided to update the theme of my blog along with the upgrade to Wordpress 2.8, browsed through the new Wordpress themes, and came across this one. It’s called “Inanis Glass”, I love the boxes around everything, even though it does make the page load time a bit heavy, I dig it. The “Start Menu” thing at the bottom is a bit overkill, but it’s sufficiently out the way to not be a bother.
Here’s to new beginnings! Again!
Articles on The Incredible Blog
I was recently approached by Jason Bagley to write some gaming-related articles for The Incredible Blog, Incredible Connections online blog where they connect online with gamers, techies, gadgetphiles and more. Now, before you starting throwing up your arms and going wild, this is actually a good thing. I don’t see any other major retailers doing any kind of attempt to connect with *their* loyal and/or pottential customers, things can only go well from here on out, and I’m happy to be part of the team that is giving them that edge.
At the moment, I will be contributing about two blog posts per week to The Incredible Blog, so go on, look over there and subscribe to the RSS feed, you’ll find a nice steady source of gaming, gadget, hardware and software news, and every now and again you’re sure to find some news on incredible specials and great competitions for lovely prizes.
I’ ve written two posts for them so far, firstly a “confirmation” of Harry Potter and a second Indiana Jones outing into the Lego world, and then a note about Halo Wars being the best-selling strategy game on the XBox 360 by selling over a million copies in less than 3 weeks.
MSSQL and ON UPDATE
I had to add a column to a database table on an MSSQL server today. It had to have the most recent update/insert time that the row was inserted/updated. MySQL has a very easy way of doing this with a TIMESTAMP column type, with a DEFAULT value of CURRENT_TIMESTAMP, and then also an additional ON UPDATE CURRENT_TIMESTAMP clause in the column definition to auto-update the value when the row is updated.
So I thought that if MySQL could do it, so should MSSQL be able too, right? Wrong. I’m not expert in MSSQL, I know MySQL fairly well, so my first surprise was to find out that the TIMESTAMP column type in MSSQL is *so* not the same as in MySQL, and in fact is rather completely useless in this example.
The solution turned out to be external to the table definition, by using a trigger.
So here’s how you update a column in your table with the current time whenever that row is update. I’m assuming you know your way around MSSQL and it’s multitudes of tools available, so I won’t be giving you screenshots.
First, add a column to your table as either a DATETIME or SMALLDATETIME, make the default value be: (GETDATE())
The default value takes care of setting the value of the column to the current date/time when a new record is inserted.
Then, add a trigger onto your table, that looks similar to this:
CREATE TRIGGER trg_updateLastUpdated ON [dbo].[your_table_name]
FOR UPDATE
AS
if not update(last_updated)
UPDATE your_table_name
SET last_updated = GETDATE()
FROM your_table_name
INNER JOIN Inserted
ON your_table_name.unique_id = Inserted.unique_id
And that’s that. The trigger makes sure to check that it’s not the last_updated column’s UPDATE that triggers the trigger, as without it, it will cause some nasty recursion to happen.
Your INNER JOIN can be on multiple columns too, if you have more than one column that is required to uniquely identify the single row that you’re updating.
Yes, you could probably update the last_updated column’s value from within whatever code you’ve got, that is an alternative, depending on exactly what you use that column for.
Anyway, this solution worked for me. Did it work for you?
It seems like for a limited period only, the fantastic 
