Image Image Image Image Image Image Image Image Image
doyleras

By

March 31, 2017

Connecting SQL and PHP

March 31, 2017 | By | No Comments

I have now created a database of tables about the production and consumption of hydroelectricity in the final decade of colonial rule in Uganda and Kenya, i.e. the years after the construction of the Owen Falls Dam for which I have been able to digitize data (I am also trying to get comparable information from the postcolonial era). The use of phpMyAdmin in WampServer made this a straightforward process, with only the minor hiccough that, at first, I misunderstood how to save work within it. With that obstacle out of the way, it really does make generating SQL easy by using PHP shortcuts to do so.

I think I saw one exception to this, however, and found it easier just to write the SQL manually: in instances where I was generating multiple tables with the same series of keys. These instances included a set of tables that changes in the values of certain variables over time, and a set of tables that compare the same information across multiple townships in Uganda. In these instances, it was faster to cut-and-paste those tables into a new SQL script and change select values for each key than to use phpMyAdmin’s UI to create new keys and values.

Moving on to making PHP script with which to access this database, I learned another thing that the phpMyAdmin UI does exceptionally quickly: generate PHP arrays from SQL tables. I have saved these arrays in Brackets, because they will make it easier to make the form with which visitors to the site will query the database. I have revisited the education in PHP that offered in the O’Reilly “Head First” series, and on CodeAcademy. I need to write PHP script that can pull substrings from within each table (so that users can query specific data points) and that can adjoin tables (so that users can compare information across the narrow range of shared keys that I made the database around).

Submit a Comment