Labels

css (1) jQuery (7) linux (38) mac (70) php (29) python (1) svn/git (9) trac (4) ubuntu (1) virtualbox (6) vista (2) windows (14)

Saturday, 28 February 2009

PHP mysql / mysqli / pdo

With more and more hosting companies adopting mysql 5.0 and php 5.2 instead of the old php 4 and mysql 4.1 I thought I'd go and benchmark some mysql/mysqli/pdo and here are my results.

The table used has approximatly one million records.

This is the results from running a SELECT * on the table 100 times.

mysql average 2.1038151192665

mysqli average 2.1223193383217

pdo average 2.1316439843178

You can see they're all pretty even but mysql wins followed by mysqli followed by pdo

Note these don't use prepared or multi query for mysqli / pdo they use plain query

Now onto insterts, adding 100k inserts one at a time has the following results

mysql average 0.00016879864931107

mysqli average 0.00013578898429871

pdo average 0.00015307459592819

On inserts mysqli wins with pdo coming second and mysql lagging behind.

Lastly updates

A simple update query which looked something like this UPDATE `t1` SET `f1`=`f1`+1 LIMIT 1 run 100k times

mysql average 0.00015682008266449

mysqli average 0.0001266986322403

pdo average 0.00013525368928909


Very similar to when running inserts mysql > pdo > mysql

The verdict with 2 points for coming first 1 point for coming 2nd and 0 points for coming 3rd we have

mysql 2
mysqli 5
pdo 2

So looks like mysqli is the fastest.

Saturday, 21 February 2009

Linux/Unix Show only hidden (dot) files

Not sure if I've posted this before but to show just hidden (file starting with a .) on linux/unix type

ls .??*

Tuesday, 17 February 2009

Repair scratched glasses

Have you ever scratched your glasses and now every time you wear them all you see is the scratch? Well I have.
Recently I read on Lifehacker a way to repair them.

Assuming you have polycarbonate glasses (new ones will be) and have a UV/Anti glare coating (probably will if you had any extras) you can use Amrour Etch Glass Etching Cream to remove the coating on the glasses which is actually what is scratched.

Since armour etch is american you can't get it in the UK or elsewhere but you can buy it off ebay like I did for around $10 which as of writing is around £7.50.

Considering a new pair of glasses could easily be £100 or £30-£50 for just new lenses it's a steal!

Debugging Javascript in Internet Explorer

As anyone who has ever tried to debug javascript in IE will know..you can't really it has a piddly little error saying "Error on line XX" but doesn't tell you what file..handy.

Anyway after a quick google I remembered the microsoft script debugger!

Download it here

Once downloaded install it then in IE go to tools > options, click the advanced tab, then uncheck "Disable script debugging (Internet Explorer)" and "Disable script debugging (other)".

Then restart IE and when something gets messed up it will alert you and ask you if you want to debug, tell it you do and it'll show you the problem line.

Vista users will have to allow the add-on so you may need admin rights.

Saturday, 14 February 2009

PHP HashBang

I've just been writing a php script and want to use a different php.ini file for the php-cli now the problem is typing

#/usr/bin/php-cli -c /pathtoinifile/php.ini doesn't work because the standard linux shell only parses one argument.

Simple solution, take the space out after the -c

#/usr/bin/php-cli -c/pathtoinifile/php.ini

That will work.

Wednesday, 11 February 2009

Genius!

I've been having a problem on and off with suPHP and cpanel, the problem was it brings up an internal server error and suphp_log says "Directory / not owned by {username}" where {username} is the user executing the script.

I'd not managed to solve it so asked my friend Simon his google skills seem better than mine he managed to find http://www.mail-archive.com/suphp@lists.marsching.biz/msg00619.html and low and behold my / and various other folders weren't owned by root! They were owned by a deleted user (602), it turns out when I installed zmanda then uninstalled it somewhere along the line the ownership got changed to the zmanda user which was then deleted.

So after running
find / -user 602 -exec chgrp root {} \;
find / -user 602 -exec chown root {} \;

All works!