renameColumn() public method

Renames a column.
public renameColumn ( string $oldName, string $newName )
$oldName string The current name of the column.
$newName string The new name of the column.
Exemplo n.º 1
0
 public function test_renameColumn_shouldDoNothing_IfGivenColumnDoesNotExist()
 {
     $this->row->setColumn('nb_visits', 11);
     $this->row->renameColumn('nb_hits', 'nb_pageviews');
     $this->assertFalse($this->row->hasColumn('nb_hits'));
     $this->assertFalse($this->row->hasColumn('nb_pageviews'));
     $this->assertEquals(11, $this->row->getColumn('nb_visits'));
 }
Exemplo n.º 2
0
 /**
  * Rename a column in every row. This change is applied recursively to all subtables.
  *
  * @param string $oldName Old column name.
  * @param string $newName New column name.
  */
 public function renameColumn($oldName, $newName)
 {
     foreach ($this->rows as $row) {
         $row->renameColumn($oldName, $newName);
         $subTable = $row->getSubtable();
         if ($subTable) {
             $subTable->renameColumn($oldName, $newName);
         }
     }
     if (!is_null($this->summaryRow)) {
         $this->summaryRow->renameColumn($oldName, $newName);
     }
 }
Exemplo n.º 3
0
 /**
  * Rename a column in every row. This change is applied recursively to all subtables.
  *
  * @param string $oldName Old column name.
  * @param string $newName New column name.
  */
 public function renameColumn($oldName, $newName, $doRenameColumnsOfSubTables = true)
 {
     foreach ($this->getRows() as $row) {
         $row->renameColumn($oldName, $newName);
         if ($doRenameColumnsOfSubTables) {
             if (($idSubDataTable = $row->getIdSubDataTable()) !== null) {
                 Manager::getInstance()->getTable($idSubDataTable)->renameColumn($oldName, $newName);
             }
         }
     }
     if (!is_null($this->summaryRow)) {
         $this->summaryRow->renameColumn($oldName, $newName);
     }
 }