Skip to content


Open Data Internship – Week 1 – The code Jungle

Wandering through the ruins of this civilisation I come across a strange totem in the middle of the road, it makes no sense for it to be there so I examine it closely, its secrets no closer to being uncovered. Then I notice a small plaque, with some prehistoric writing on it, I was previously unaware that this civilisation had mastered writing so I eagerly tried to read it “//Down here as PHP 5.5 or less doesn’t support expressions as initializers.” And suddenly the totems position made sense.

It is my first week here in the Technical Innovation and Development team working as an open data intern, and whilst looking for a starting point for my time here I decided to look to the past and see what last year’s intern did with their time here. Conveniently they wrote a pseudo-weekly blog about their time here and so I settled down with a cup of tea to read what they had done. This went well for about the first five minutes until I came a sample of a SPARQL query. I had never seen anything quite like it before so I started investigating. SPARQL is an Resource Description Framework (RDF) query language, I understand RDF to be a format by which data is expressed as Triples containing a ‘subject’, ‘predicate’ and ‘object’. The ‘subject’ is a reference to the object being described such as ‘buiding32’, the ‘predicate’ denotes a type of the ‘object’ such as ‘residential’ and the ‘object’ denotes a value such as ‘false’. Having never come across either RDF or SPARQL before it took a little while to get my head around this but I got there in the end and building on what was done last year I was able to retrieve information about what buildings on campus do not have images or geo-data in the university’s University ‘Building’ Open Data Set, removing all members of the ‘Item Hidden from Lists’ Data set. I achieved this using the MINUS operator which was implemented in SPARQL 1.1, which allows for the elements in set A which are also in set B to be removed from set A in the case ‘A MINUS {B}’.

The second thing I have worked on this week was working my way through the source code of the data gathering app that last year’s intern wrote, available here. Doing this made me feel a bit like a new age explorer as a whilst the application seems well coded, comments are few and far between which can leave me wandering through the jungle of code longer than necessary and underlines the need for well documented code to improve the lifespan of it. This was particularly frustrating when I was starting out and having hosted a local server on my machine and was trying to get the app to run I was running into a large number of database related problems. I eventually found the problem by sifting through error logs which were complaining that the mysql libraries were unavailable. This was because I was using PHP 7, and these libraries were removed in PHP7 having been deprecated in PHP5.5 for security reasons. Putting the original code on a server with PHP5.5 solved all the database connection problems and made the app functional again. I am now going through and trying to replace these mysql references with mysqli ones instead to improve the quality of code.

Posted in PHP, SQL.

Tagged with , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.