This week I have spent my time working on following issue:
Import/Export Progress bar
https://github.com/phpmyadmin/phpmyadmin/issues/6311
https://github.com/phpmyadmin/phpmyadmin/issues/12401
First I made changes in the phpmyadmin configuration sql table and added one extra table to track the progress status.
CREATE TABLE IF NOT EXISTS `pma__progress` (
`uuid` varchar(36) NOT NULL,
`type` varchar(64) NOT NULL,
`data` text NOT NULL,
`value` int(50) unsigned NOT NULL,
`total` int(50) unsigned NOT NULL,
UNIQUE KEY `uuid` (`uuid`)
)
COMMENT='Saved import/export progress data'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
Then I learnt how to insert data in phpmyadmin configuration database. Then from the mailing list I got this link to get started
https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/tracking.lib.php#L246 So finally I was able to update data in the progress table as the new table is exported.
$cfgRelation = PMA_getRelationsParam();
$sql_query = " SELECT * FROM " .
PhpMyAdmin\Util::backquote($cfgRelation['db']) . "." .
PhpMyAdmin\Util::backquote($cfgRelation['tracking']) .
" WHERE db_name = '" .
$GLOBALS['dbi']->escapeString($_REQUEST['db']) . "' " .
" AND table_name = '" .
$GLOBALS['dbi']->escapeString($_REQUEST['table']) . "' " .
" ORDER BY version DESC ";
PMA_queryAsControlUser($sql_query);
Then I used the setInterval() to update the progress on the page.
var progressInterval = setInterval(function () {
$.post('progress.php', params, function (response) {
if (response.success === true) {
// do something
}
});
},
One more thing I missed mentioning below issue in my previous blog post. This was completed last week.
Double Character Encoding Issue:
https://github.com/phpmyadmin/phpmyadmin/issues/9419
removed double charset encoding
https://github.com/phpmyadmin/phpmyadmin/pull/13457
I have used phpmyadmin sql parser to do this.
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Utils\Query;
$query = 'SET NAMES latin1';
$parser = new Parser($query);
$flags = Query::getFlags($parser->statements[0]);
echo $flags['querytype'];
Next Steps
This was my eighth week progress. I will post an update for this week soon.
This was originally posted on my medium account.
No comments:
Post a Comment