deleteTracking() public static method

Removes all tracking data for a table or a version of a table
public static deleteTracking ( string $dbname, string $tablename, string $version = '' ) : integer
$dbname string name of database
$tablename string name of table
$version string version
return integer result of version insertion
Exemplo n.º 1
0
/**
 * Deletes a tracking version
 *
 * @param string $version tracking version
 *
 * @return string HTML of the success message
 */
function PMA_deleteTrackingVersion($version)
{
    $html = '';
    $versionDeleted = Tracker::deleteTracking($GLOBALS['db'], $GLOBALS['table'], $version);
    if ($versionDeleted) {
        $msg = Message::success(sprintf(__('Version %1$s of %2$s was deleted.'), htmlspecialchars($version), htmlspecialchars($GLOBALS['db'] . '.' . $GLOBALS['table'])));
        $html .= $msg->getDisplay();
    }
    return $html;
}
Exemplo n.º 2
0
// Get the database structure
$sub_part = '_structure';
list($tables, $num_tables, $total_num_tables, $sub_part, $is_show_stats, $db_is_system_schema, $tooltip_truename, $tooltip_aliasname, $pos) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
// Work to do?
//  (here, do not use $_REQUEST['db] as it can be crafted)
if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
    Tracker::deleteTracking($GLOBALS['db'], $_REQUEST['table']);
    PMA\libraries\Message::success(__('Tracking data deleted successfully.'))->display();
} elseif (isset($_REQUEST['submit_create_version'])) {
    PMA_createTrackingForMultipleTables($_REQUEST['selected']);
    PMA\libraries\Message::success(sprintf(__('Version %1$s was created for selected tables,' . ' tracking is active for them.'), htmlspecialchars($_REQUEST['version'])))->display();
} elseif (isset($_REQUEST['submit_mult'])) {
    if (!empty($_REQUEST['selected_tbl'])) {
        if ($_REQUEST['submit_mult'] == 'delete_tracking') {
            foreach ($_REQUEST['selected_tbl'] as $table) {
                Tracker::deleteTracking($GLOBALS['db'], $table);
            }
            PMA\libraries\Message::success(__('Tracking data deleted successfully.'))->display();
        } elseif ($_REQUEST['submit_mult'] == 'track') {
            echo PMA_getHtmlForDataDefinitionAndManipulationStatements('db_tracking.php' . $url_query, 0, $GLOBALS['db'], $_REQUEST['selected_tbl']);
            exit;
        }
    } else {
        PMA\libraries\Message::notice(__('No tables selected.'))->display();
    }
}
// Get tracked data about the database
$data = Tracker::getTrackedData($_REQUEST['db'], '', '1');
// No tables present and no log exist
if ($num_tables == 0 && count($data['ddlog']) == 0) {
    echo '<p>', __('No tables found in database.'), '</p>', "\n";
 /**
  * Test for Tracker::deleteTracking()
  *
  * @return void
  * @test
  */
 public function testDeleteTracking()
 {
     $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock();
     $sql_query = "/*NOTRACK*/\n" . "DELETE FROM `pmadb`.`tracking`" . " WHERE `db_name` = 'testdb'" . " AND `table_name` = 'testtable'";
     $dbi->expects($this->exactly(1))->method('query')->with($sql_query)->will($this->returnValue('executed'));
     $GLOBALS['dbi'] = $dbi;
     $this->assertEquals(Tracker::deleteTracking("testdb", "testtable"), 'executed');
 }