Archive for August, 2009

Published by Rolf on 25 Aug 2009

Simple example of using a subquery in CakePHP

I hunted for awhile but never could find a simple example online showing how to do a subquery. For example suppose you have the usual Posts and Comments models, but for whatever reason could not bind them on the usual “id” foreign keys. So if you wanted to query for all the Posts that have at least 10 Comments, while joining them on some key condition, you’d want to use a subquery like:

SELECT Post.id, Post.title
FROM posts Post
WHERE Post.id IN
(SELECT p.id FROM posts p, comments c WHERE c.col_x = p.col_y AND c.total > 10)

I couldn’t find any sample code for this. After a lot of trial and error I was finally able to do this (using pagination):

1
2
3
4
5
6
$blocks = $this->paginate(
					array(
						'field1' => 'value1', // etc.
						'1' => '1 AND Post.id IN (SELECT p.id FROM posts p, comments c WHERE c.col_x = p.col_y AND c.total > 10)'
						)
					);

Enjoy.

Published by Rolf on 17 Aug 2009

Getting Firefox 3.X to update successfully on Vista

For some time now (months, if not years), my Firefox has been unable to update automatically. It keeps erroring out every time it tries to apply the update. Turns out I’m not the only one reporting it, and it’s been around since 2007 at least.  You can blame this on Mozilla, or on Microsoft (since here, UAC is definitely a factor). In this case I think we need to blame Mozilla – working around UAC is very well documented and if little tiny startups can figure it out, Mozilla should be able to as well.

The folks at the forum above had the right idea, but you need a variation to get it to work on Vista.

  1. Open an Administrator command prompt
  2. Do
    icacls "c:\Program Files\Mozilla Firefox" /grant Everyone:F /T
  3. This step may not be needed, but I did it anyway: delete the contents of C:\Users\USERNAME\AppData\Local\Mozilla\Firefox – this is, I think, where the info about the updates gets stored.

Now restart Firefox and it should be able to update itself.  Note of course that you’re defeating the purpose of UAC here, but as I said, it’s time to blame Mozilla.