Last week I somewhat improved my implementation of jqplot porting for status tab. Earlier the page could hold only one chart at a time, means that if a user switched among tabs on the status page while a live chart was on progress, when switching back to the same tab the chart was no more there. It had to be, as jqplot should know the dimensions of the target div to plot the chart, which became unavailable on switching to some other tab. Now after I did a chart replot on tab showing up again, the chart starts again. So multiple charts can now resume on switching tabs.
Also, I started migrating the status => monitor tab to jqplot.
This week I continued working on highcharts to jqplot migration of Status page charts. Main ask accomplished was the migration of live traffic chart and live connections/processes chart to jqplot. Live Queries chart was already migrated to jqplot in the last week.
The new jqplot live charts like highcharts, are customizable for refresh rate, also I have added a customization for the number of data points visible at one time using select list.
Under Status page, there are several tabs of which Server and Traffic have charts plotted using jqplot. In an event of switching between these tabs when the live charts are running under both tabs, I noticed some misbehaviour and jqplot seemed to shorten the width of the charts to half their original width. So, the next task is to make multiple charts work properly at the same time.
This week I started working on highcharts to jqplot migration of live query statistics chart (Status => Query Statistics => Live Query Chart). Initially, we were facing a problem with jqplot’s dateAxisRenderer plugin, that it crashed when plotting a chart with very small time intervals. But a fix provided on  solved the problem, though the fix is not a part of official jqplot release yet.
The next problem was to make the live chart move to left with time, initially I tried to make that work by shifting the data values in the array provided as data to jqplot as in . It produced the moving effect to some extent but was not as seamless as highcharts. Also the number of data points on x-axis kept fluctuating making it hard to read the chart.
So in  I tried moving the chart to left by tweaking the min/max values of charts’ x-axis on every replot. Now the live chart seems to be more viewable, also it gets easily re-adjusted on refresh-rate change.
This week I planned to work on the InnoDB relations support feature for db_qbe search. Though I couldn’t come up with some committed progress towards the feature’s implementation, but I studied closely how LEFT JOIN creation currently happens in case of PMA’s internally defined relations. And I tried to make myself understand what exactly needs to be done to integrate InnoDB relations.
Currently, LEFT JOIN generation procedure involves following order in libraries/DBQbe.lib.php:-
=> _getIndexes() // provides us which tables have UNIQUE and INDEX columns and which are with/without valid where clauses
=> _getLeftJoinColumnCandidates() // provides us with best possible table.columns based on UNIQUE, INDEX, with/without valid where clause info
=> _getMasterTable() // provides master table for LEFT JOIN from table.column candidates (smallest based on records count)
=> _getFromClause() // sets from_clause = master_table + PMA_getRelatives(all_tables, master_table)
=> PMA_getRelatives() // looks for master->foreign and foreign->master entries in PMA internal relations table and generates LEFT JOIN clause.
So, only PMA_getRelatives finally looks for PMA’s internal relations and before that we just try to find out the best master table. So while thinking about introducing InnoDB relations into this flow, I still need to ascertain whether the same master table is to be used in case of InnoDB relations too and also I need to decide how to use PMA_getForeigners() (that provides us InnoDB foreign relation details for a table) in PMA_getRelatives().
And as it was taking too much time for now, I have currently moved on to PMA’s ‘highcharts‘ to ‘jqplot‘ migration and I’ll get back to InnoDB feature later.
This week I continued refactoring in db_qbe.php. A new class PMA_DbQbe was created to accommodate the db_qbe functionality, and db_qbe.php now creates a new instance of PMA_DbQbe to execute all qbe related operations. About functionality, it seems almost unaltered to me as of now, after fixing a few introduced bugs reported by Marc. I am happy that the refactoring on schedule is complete except testing, and I will continue testing the refactored code to fix any other bugs.
As of now, database qbe search only supports ‘PMA internal relations‘ for creating LEFT JOINS automatically in case of related tables. I plan to introduce InnoDB relations into QBE search as suggested by Marc. The InnoDB relations data is already available but the main task is to use it in relation.lib.php(PMA_getRelatives) to somehow create LEFT JOINS out of it.
This week I continued refactoring in db_qbe.php. The remaining code was mainly responsible for SQL query generation using the inputs provided by user. The code was converted into functions involving the LEFT JOIN generation code. The following new functions were formed:-
- PMA_dbQbeGetSelectClause // Provides SELECT clause for the query
- PMA_dbQbeGetWhereClause // Provides WHERE clause for the query
- PMA_dbQbeGetOrderByClause // Provides ORDER BY clause for the query
- PMA_dbQbeGetInsDelAndOrCell // Provides options to add/del criteria rows
- PMA_dbQbeGetInputboxRow // Provides criteria inputbox row
- PMA_dbQbeGetInsDelAndOrCriteriaRows // Provides criteria inputbox row
- PMA_dbQbeGetLeftJoinColumnCandidates // Provides columns for LEFT JOIN
- PMA_dbQbeGetIndexes // Provides UNIQUE AND INDEX columns
- PMA_dbQbeGetMasterTable // Provides master table
- getWhereClauseTablesAndColumns // Provides tables and columns containing valid WHERE clause
- PMA_dbQbeGetFromClause // Provides FROM clause
Apart from that the mid-term assessments were also scheduled during this week and I passed through mid-term to continue the remaining project. I have moved the new functions to a new library file libraries/db_qbe.php. Next I plan to work out some InnoDB foreign key support issues in db_qbe search with Marc.
This week I started working on db_qbe.php. The script is responsible for providing ‘Query By Example‘ search on a database. The user can visually form a query using this feature and execute it with minor manual modifications. As about refactoring, the script contained a lot of HTML-PHP mix used to display the ‘qbe‘ form. So I have formed several functions to display the search form.
The following new functions provide different <tr> elements for the search form:-
- PMA_dbQbegetColumnNamesRow // Provides Column Names Select Options
- PMA_dbQbegetSortRow // Provides Sorting options
- PMA_dbQbegetShowRow // Provides Show checkboxes
- PMA_dbQbegetCriteriaInputboxRow // Provides Input boxes
- PMA_dbQbeGetAndOrColCell // Provides And/Or modification options
- PMA_dbQbeGetFootersOptions // Provides Footer modification options
- PMA_dbQbeGetTableFooters // Provides search form’s footer
- PMA_dbQbeGetTablesList // Provides tables select list
- PMA_dbQbeGetModifyColumnsRow // Provides columns ins/del options
Also, by the end of this week I converted database search to object oriented style. Now, db_search.php uses libraries/DbSearch.class.php as its class file. All the already set criteria variables for db_search.php are now being initialized in setCriteriaParams() and a new instance of PMA_DbSearch is created in db_search.php to conduct database search operations.
By the mid of the upcoming week, I plan to convert QBE search to OOP style, which would almost finish the scheduled refactoring work of my project. After that I plan to work on PMA’s ‘highcharts‘ to ‘jqplot‘ migration with Marc apart from minor improvements in the refactoring done so far.
This week, I started with further improvements in db_search.php. The HTML-PHP mix responsible for displaying the search results was cleaned and replaced with a function PMA_dbSearchGetSearchResults()
Going ahead, a new function PMA_dbSearchGetResultsRow() was formed out of PMA_dbSearchGetSearchResults(). PMA_dbSearchGetResultsRow() is used to fetch results row for each criteria table containing browse/delete links if the results count for that table is more than zero.
Another new function PMA_dbSearchGetWhereClause was formed out of PMA_getSearchSqls(), the new function is used for generating where clause for all criteria tables. All the functions have been now moved to a separate library file libraries/db_search.lib.php. Apart from that, some variable name improvements were also made The improvements in db_search.php are almost complete and next week I plan to start with db_qbe.php.
This week I initiated the refactoring of db_search.php script that provides database search feature in phpMyAdmin. I started by fixing an encountered bug:-
After the results for a search-entry were displayed; while attempting to delete any table’s entries using the delete link, it did not show the query’s execution result message(error or fine).
The issue was fixed for now, though there is need for implementing browse/delete functionality using proper AJAX method.
Apart from that two new functions were formed :-
- PMA_dbSearchGetSelectionForm() // Displays database search form
- getResultDivs() // Provides HTML divs for search results to be displayed
Under progress :-
The part of script responsible for generating and displaying search results is now being converted to proper functional style.
This week saw the conversion of search scripts to object-oriented style. A new class PMA_TableSearch has been formed to accommodate all table search functionalities. The PMA_TableSearch class can be instantiated for normal as well as zoom search, public method getSelectionForm() is then used to display the respective search form. Similarly after the form submission, buildSqlQuery() is used to generate SQL query for execution.
In case of zoom search(as it doesn’t use AJAX to fetch plot), the previously submitted form data is displayed using getColumnProperties() method. This public method is also used to update column information in zoom search column-select list. Another public method getZoomResultsForm() is used to display the zoom search results form. Apart from above mentioned publicly used methods, several other private methods that were formed during last weeks, now form part of the PMA_TableSearch class.
As of now, the scripts tbl_select.php and tbl_zoom_select.php appear to be quite cleaned up of unreadable code and are quite readable now. Previously used library file tbl_select.lib.php has been replaced with TableSearch.class.php. Moving on, next week I plan to take up db_search.php, also suggestive improvements will be done in PMA_TableSearch.