Monthly Archives: December 2010

How to select distinct with Doctrine_Query 1

There is a bug with doctrine and many tickets have been opened for it from what I saw. Doing the following in a query will return no result

$q = Doctrine_Query::create()
	->orderBy('datetime_scraped desc');

The solution is to alias the distinct column like below

$q = Doctrine_Query::create()
	->select('distinct(datetime_scraped) as datetime_scraped')
	->orderBy('datetime_scraped desc');

How to Install Memcache on Mac OS X

Hopefully I’ll save somebody days of work here. If you’re on a mac, unfortunately you can’t just run “pecl install memcache” (well you can, but it won’t work). I’m using Zend Server CE, which is a 32 bit application and if you run the above command to install from pecl, you’ll get a 64 bit version installed. Oh, and let’s be clear, we’re working with Memcache and not Memcached (they are very similar, but different).

OK, how to make it work. Open terminal and run the following commands –

  1. cd /tmp
  2. pecl download memcache
  3. tar xzf memcache-2.2.6.tgz (or whatever file and version you downloaded)
  4. cd memcache-2.2.6
  5. OK, here is a tricky one. Copy this line and change the path on the end to the location of your phpize executable and paste into terminal.

    ./configure MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS=’-O3 -fno-common -arch i386 -arch x86_64′ LDFLAGS=’-O3 -arch i386 -arch x86_64′ CXXFLAGS=’-O3 -fno-common -arch i386 -arch x86_64′ –with-php-config=/usr/local/zend/bin/php-config

  6. make
  7. make install

Restart apache and you should be good to go.

Apache 2.2 “It works” message – vhost and hosts file

I recently switched from using windows to a mac. With windows, you can structure your hosts file like this localhost test.localhost

However, if you do this and you’re on a mac like me and go to test.localhost, you’ll get a “It works!” message no matter how your vhost is configured. The solution is to structure the hosts file for the IP address on a single line like this – localhost test.localhost