I’ve been working on a site powered by Drupal and needed to find the number of rows a database query returned. Simple enough and quite common procedure. But, the Drupal database API no longer offers the db_num_rows() function.
I had a quick Google around and the answered seemed to be to run the query twice but the second time using a count query. Two calls to the database when only one is necessary? Not on my watch. The piece of code is to appear on the home page so it will be called upon frequently.
My solution was too loop through the results set and add the formatted HTML to an array. Then check if there are any items in the array, if so loop through it an output them if not display the message that there are currently no results.
I know it’s still doubling up but I think it is a slightly more elegant solution than the double database call.
I’m really enjoying using CodeIgniter, it’s an excellent framework and has a side benefit of helping to structure your files neatly.
I’ve been working on my first login form using it, and whilst there are lots of tutorials going through this common process I encountered a “problem” with the CodeIgniter sessions persisting when the user closed their browser.
A bit of searching around and I came up with a few recommendations.
The first is to set the $config[‘sess_expiration’] to 0
This however has the effect of creating a cookie which actually lasts 2 years due to code in the system/libraries/Session.php file
The next was to set the $config[‘sess_expiration’] to -1
This just didn’t work for me full stop. When I logged in it saved the session variable then when I went to the next page it had disappeared.
The solution I have used came from this page.
It’s pretty quick to implement the code and you can have control over the expiration time as well as choosing whether your cookie should be persistent.
And now it’s implemented I intend to copy the Session.php file into every project I create that requires sessions. I can handle having to paste in one line of code to the config file.
my new iPhone arrived today and like everyone I love it. i’m really looking forward to doing some work on mobile css and optimising sites for mobile use.
any interesting discoveries will be posted here.
I’ve been playing around with PHP frameworks latley and have just started coding my first major project using CodeIgniter.
I’ll post updates as I progress but roughly this project interacts with data from different organisations and acts as a central point for approval of records and the sharing of data.
A lot of the sites we do in work involve using a Google map, some are simple and just allow the user to choose a spot which populates input fields for latitude and longitude. Others contain large data sets and information about the point, which is normally displayed in one of the Google map bubbles.
Using our standard library code for implementing a map and allowing the user to pick a latitude / longitude point IE6 was only displaying a grey background with the Google copyright.
So I started from a blank page and managed to get a basic map up and working. Then stepping through my real page I discovered that something in the style sheet was causing the error. I know that IE can throw a wobbly if you don’t declare the width and height of the map div, in particular the width. But both these values were declared in pixels.
I eventually got to the bottom of it and it was a png fix I have been using for IE6. I know it’s not practical to make sites look exactly the same across browsers but when you have a large portion of IE6 users it’s hard to tell them that they will receive a version of the site that doesn’t match up to what they were expecting.
With the release of the Nexus One phone I decided to look into Android phones and development a little more last night. After reading a quick couple of tutorials I had a simple app that would allow you to update your Twitter status.
At first glance it seems to be simpler to construct Android apps over iPhone apps. I’ve also done a bit of work on iPhone apps and the entry to these seems a lot higher.
I don’t think Nexus One will topple the iPhone, there is still a very “cool” factor to owning an iPhone that I don’t think the Nexus One will be able to gain.
I’m due to get a new phone in a couple of months and I am considering an Android but even I’m still tempted by the iPhone. Then being in England where it could be a while till we get a decent tariff for the Nexus One could also be a barrier.
I’ve been meaning to set up a new blog for a while now and after a few friends had gone to the bother I decided it was time for me to get on board.
This is along with other things like updating the design and content of my portfolio website, learning new technologies and improving on old ones.
This blog will be a mixture of things from personal to professional and anything else I feel will benefit it.
Happy new year (decade)
Dr Nova Mieszkowska is a Fellow at the Marine Biological Association who specialises in Climate Change and Marine Biodiversity.
Her pages were created to reflect her studies based on a colour palette that was derived from Dr Mieszkowska’s own photography.
The site includes a jQuery lightbox plugin for images on information pages as well as the Galleria plugin for the gallery pages.
Ed Smith is a talented photographer based in Falmouth, Cornwall.
The Ed Smith Photography website enables Ed to showcase his work and the user can to learn a bit more about him.
Working with designer Random Badger the site has been kept clean and simple with the focus on Ed’s excellent work.
In addition to the main site there is a blog, built on WordPress, where Ed can update users on his latest projects.