Thursday, June 21, 2007

How to get number of rows in MySQL while using LIMIT cause

Normally, in MySQL, if you want to get number of rows to render page list while limit the output to pages, you would have to execute them as two queries like these:

SELECT COUNT(*) FROM foo WHERE bar = 1
SELECT * FROM foo WHERE bar = 1 LIMIT 15


However, I was curious about how to optimize this process. I think there must be a better way that I can count the number of rows that matching my condition and limiting number of rows returned at the same time.

After I google a bit, I found the answer using SQL_CALC_FOUND_ROWS. I think this is better than the above example.

SELECT SQL_CALC_FOUND_ROWS * FROM foo WHERE bar = 1 LIMIT 15
SELECT FOUND_ROWS();


Thanks Array Studio Workshop for this wonderful tip!

Friday, June 15, 2007

My 10 reasons why I switched to mac


I think everybody has a reason on why they do such thing. After 3 months of switching to my first mac, I think this is the time that I should shout to the world what's my decision to do such thing, without looking back!

1. I write platform-independent program
I'm a PHP programmer, and PHP is platform-independent. So, it means that I don't have to stick around only one OS to write my code. There're so many IDEs and editors for PHP avaliable today on every platform, and my favorite is Zend Studio. I think Zend Studio did a really great job as an IDE for PHP programmer. I think it also make my website becoming web-standard, since I have more concern on running it on Firefox and Safari, not only in IE as usual.

2. Java is so slow on Windows
As I mentioned above, I use Zend as my main IDE for my development. I used to use Zend under Windows. However, it usually took forever for IDE window to refresh. After I tried Zend Studio on the mac, the speed is so fast! I don't think I want to go back and use Zend on Windows anymore!

3. I love OSX interfaces
Someone said that, the more great working environment, the more productivity will be. I love Aqua style of Mac OSX. I think it gives me a lot of idea on how to implements a wonderful program interface, because even you didn't do anything fancy with the CSS by the way, it would still looks great when you open it on Safari.

4. It's secure (I think)
I had an experience when I was in sophomore. My friend own a notebook with lots of viruses and connected to the same AP as I did. What was the result? His notebook was trying to spawn viruses on my computer. However, on the mac, I really doesn't have to care about that at all.

5. Everything is so simple
I remembered once when I have to install some program and I have to wait around 30 min for the installation of that program to complete. On mac, I just download that program as disk image, mount it, drag it to my Application folder, eject that image, and that's it! Also, when I want to uninstall that program, I just drag it to the trash and it just gone. No worry about leftover DLL and stuff.

6. Exposé
I like to open more than 3 apps one time. How would you navigate between applications? Alt+Tab? There's a thing on the mac called Exposé which will preview all windows which are currently open. I love to press F9 and navigate to the application I like on that way!

7. Spotlight
It's such a killer feature of OS X Tiger. I usually save my work in the well-organized folder. However, sometime I can't say it 'well' organized because I couldn't find the file I want. However, after I have Spotlight, I don't have that problem anymore. I just press the shortcut to bring Spotlight on, type the file name in, and my file is in the list! It's such an easy way to find stuff in computer.

8. I can live on the same world with Windows
All of my friend still using Microsoft Windows. If I made a switch, I still have to be able to share my file with them. Mac OS X allows me to do that. I can turn on Windows File Sharing, and my friend would see my computer as if it's Windows computer. It's just so compatible.

9. I love the machine design
I can't resist that, I was impressed by mac because of its design. I'm using Macbook Pro since I love its aluminium case. I don't really taking care of my notebook very well, so if I use an aluminium-case notebook, I don't have to worry about the scratches anymore. It's so-good.

10. Everything!
I don't know, I think from the first day that I switched to mac, I think my life couldn't be more wonderful than this. I love to work on my machine, carry it with my anywhere, as it is my own child! I think this switching is worth, and I won't look back to get a Windows PC for a long long time. ;-)

Tuesday, June 5, 2007

No free Blogger desktop blog-posting client?


I have looked at the list of the third-party apps in Blogger's Help page today for a blog-posting client which I can use it on my mac. However, I couldn't find any of them to be freeware. So, I think I'll have to open Safari every time I want to publish my blog.

I wish I could write one application like this by myself ..

UPDATE: I was able to find Blogger widget on Blogger's front page. However, the widget doesn't have a field to tag my post. So, for now, I would still have to update this blog on Safari ..