PMA\libraries\controllers\database\DatabaseStructureController::handleRealRowCountRequestAction PHP Метод

handleRealRowCountRequestAction() публичный Метод

Handles request for real row count on database level view page.
public handleRealRowCountRequestAction ( ) : boolean
Результат boolean true
    public function handleRealRowCountRequestAction()
    {
        $ajax_response = $this->response;
        // If there is a request to update all table's row count.
        if (!isset($_REQUEST['real_row_count_all'])) {
            // Get the real row count for the table.
            $real_row_count = $this->dbi->getTable($this->db, $_REQUEST['table'])->getRealRowCountTable();
            // Format the number.
            $real_row_count = Util::formatNumber($real_row_count, 0);
            $ajax_response->addJSON('real_row_count', $real_row_count);
            return;
        }
        // Array to store the results.
        $real_row_count_all = array();
        // Iterate over each table and fetch real row count.
        foreach ($this->_tables as $table) {
            $row_count = $this->dbi->getTable($this->db, $table['TABLE_NAME'])->getRealRowCountTable();
            $real_row_count_all[] = array('table' => $table['TABLE_NAME'], 'row_count' => $row_count);
        }
        $ajax_response->addJSON('real_row_count_all', json_encode($real_row_count_all));
    }

Usage Example

 /**
  * Tests for handleRealRowCountRequestAction()
  *
  * @return void
  * @test
  */
 public function testHandleRealRowCountRequestAction()
 {
     $_REQUEST['table'] = 'table';
     $ctrl = new DatabaseStructureController(null, null, null, null, null, null, null);
     $ctrl->handleRealRowCountRequestAction();
     $json = $this->_response->getJSONResult();
     $this->assertEquals(6, $json['real_row_count']);
     // Fall into another branch
     $_REQUEST['real_row_count_all'] = 'abc';
     $GLOBALS['tables'] = array(array('TABLE_NAME' => 'table'));
     $ctrl->handleRealRowCountRequestAction();
     $json = $this->_response->getJSONResult();
     $expected_result = array(array('table' => 'table', 'row_count' => 6));
     $this->assertEquals(json_encode($expected_result), $json['real_row_count_all']);
 }
All Usage Examples Of PMA\libraries\controllers\database\DatabaseStructureController::handleRealRowCountRequestAction