Monday 17 November 2008

[innerHTML Vs. DOM] [PHP MySQL extensions]

I woke up this morning about 7am and there was a really nice sunrise outside with the cloudy sky lit up all orange, but I was too sleepy to get up so I went back to sleep and got up about 7.45am.

After breakfast I checked my email, deviantart, hotukdeals and thewebsqueeze. Clare found a small catterpillar in the iceberg lettuce (which was from Spain), so I took some photos of it. It looked like it was dead, but after I took a few photos of it it woke up and started wandering around.

Then I tried to look at some wiki sites to see how they work with editing the data and displaying the data.

After lunch I checked hotukdeals and my email. Then I did some work on my website, making the pogInfo form so it would be generated as javascript rather than coded sraight into the page. Basically I just copied the form as I had previously written it in php/html and made it into a string in php. In php I then escaped the string, which escapes any line breaks/new lines and ' chars, which would break javascript otherwise. Keeping the line breaks in there also means that the code when generated by javascript is easy to read. Then I echoed the string as a javascript variable. I made a new container div (coded into the page) to hold the form, then changed the javascript function so that when the edit button is clicked, the container div has its innerHTML changed to the variable holding the form HTML. I did searched on google, and found that using innerHTML is much faster (as well as loads less code to write) than using DOM methods.

I also changed the sql query used to get the tags. Previously I was getting all the tags row by row and putting them in an array. Then I was using a loop to stick the tags together in a string seperated by a comma and a space. Now the query uses GROUP_CONCAT to stick the tags together instead.

I was waiting for a lowepro lens case to finish on ebay, unfortunately it finished before I thought it would. I think what happened was when I refreshed the page to see how long was left, the page didn't actually refresh. So I thought there was still an hour left on the auction. Then I refreshed the page again about half an hour later and it said the auction had finished. Very annoying. I did bid on another lens pouch that hadn't finished, but got outbid for that. I'm hoping at the moment that the person who won the 5 lowepro lens pouches auction won't actually pay, and then I might get a 2nd chance offer.

I don't think I said in yesterday's blog, but I bid on (and won) a canon 100mm/2.8 Macro lens from the canon refurbished shop on ebay. It ended up about £320, only about £10-20 less than a brand new one, but since you get a year's warranty and it should have been checked by canon and be in working order (which a new lens may not be) I think it's still worth it. I hope I get a box and instructions with it though. The main reason for buying it now is not that I'm going to be doing a lot of macro soon, but that I won't be. So I can test the AF on it with the 450D and see if the AF is working properly. Then if it isn't, I can send it and the camera back to canon to get fixed and won't miss the camera because I don't have anything to shoot with it at the moment anyway.

I went on the rowing machine for a few minutes and watched an episode of MacGyver with Ben. After that I googled for 'Mysql mysqli PDO' to see which extension was best. A few threads/blogs said that PDO was slow, but one of the results said that in their initial tests PDO was much slower, but when they re-ran the tests, mysql, mysqli and PDO all worked at similar speeds. Anyway, on the official mysql site it says you should use mysqli php extension, and that you shouldn't use the mysql extension anymore as it's outdated. It suggests only using PDO if want your site to work with database systems other than mysql.

After dinner I watched Lost with Maccy and Ben, then watched the Gadget Show, then checked HotUKdeals. The weather today was grey skies raining slightly all day (apart from at sunrise where I don't think it was raining and the clouds were orange instead of grey).

Food
Breakfast: Strawberry crisp cereal; orange juice.
Lunch: Mature cheddar cheese sandwich; packet of Chilli flavour Doritos; banana; slice of cherry madeira cake; breakaway; cup o' tea.
Dinner: Chicken & mushroom pie; baked beans; poatoes; roast parsnips; cauliflower. Pudding was Bread pudding (made in the miguelwave) with custard.

No comments: