Set empty "nullable" values to null.

@param $table
179743
protected function nullifyEmptyNullables($table)
    {
        $columns = scheme()->columns($table);

        foreach ($this->data as $key => &$value) {
            if (!array_key_exists($key, $columns)) {
                continue;
            }

            if (!$columns[$key]->getNotnull() && empty($value)) {
                $value = null;
            }
        }
    }
68559
public function setTable($table)
    {
        if (!is_array($table)
            && !($table instanceof DataTableInterface)
        ) {
            throw new Exception("DataTable renderers renderer accepts only DataTable, Simple and Map instances, and arrays.");
        }
        $this->table = $table;
    }
924309
public function filter($table)
    {
        $rows = $table->getRows();
        foreach ($rows as $row) {
            $row->removeSubtable();
        }
    }
342744
public function filter($table)
    {
        if (!isset($this->nameToAppend) || '' === $this->nameToAppend || false === $this->nameToAppend) {
            return;
        }

        foreach ($table->getRows() as $row) {
            $columns = $row->getColumns();

            foreach ($columns as $column => $value) {
                $row->deleteColumn($column);
                $row->setColumn($column . $this->nameToAppend, $value);
            }

            $this->filterSubTable($row);
        }
    }
254128
public void setTable(final Table table) {
        if (table != _tableRef.get()) {
            _tableRef.set(table);

            if (table == null) {
                _comboBox.setEmptyModel();
            } else {
                _comboBox.setModel(table);
            }
        }
    }
1194986
public function from($table = null)
    {
        if ($table !== null) {
            $this->table = $table;
            $table = $this->quote($table);
        }

        $this->append(' FROM ' . $table);
        return $this;
    }
1168080
public function filter($table)
    {
        // set of all column names in the pivoted table mapped with the sum of all column
        // values. used later in truncating and ordering the pivoted table's columns.
        $columnSet = array();

        // if no pivot column was set, use the first one found in the row
        if (empty($this->pivotColumn)) {
            $this->pivotColumn = $this->getNameOfFirstNonLabelColumnInTable($table);
        }

        Log::debug("PivotByDimension::%s: pivoting table with pivot column = %s", __FUNCTION__, $this->pivotColumn);

        foreach ($table->getRows() as $row) {
            $row->setColumns(array('label' => $row->getColumn('label')));

            $associatedTable = $this->getIntersectedTable($table, $row);
            if (!empty($associatedTable)) {
                foreach ($associatedTable->getRows() as $columnRow) {
                    $pivotTableColumn = $columnRow->getColumn('label');

                    $columnValue = $this->getColumnValue($columnRow, $this->pivotColumn);

                    if (isset($columnSet[$pivotTableColumn])) {
                        $columnSet[$pivotTableColumn] += $columnValue;
                    } else {
                        $columnSet[$pivotTableColumn] = $columnValue;
                    }

                    $row->setColumn($pivotTableColumn, $columnValue);
                }

                Common::destroy($associatedTable);
                unset($associatedTable);
            }
        }

        Log::debug("PivotByDimension::%s: pivoted columns set: %s", __FUNCTION__, $columnSet);

        $others = Piwik::translate('General_Others');
        $defaultRow = $this->getPivotTableDefaultRowFromColumnSummary($columnSet, $others);

        Log::debug("PivotByDimension::%s: un-prepended default row: %s", __FUNCTION__, $defaultRow);

        // post process pivoted datatable
        foreach ($table->getRows() as $row) {
            // remove subtables from rows
            $row->removeSubtable();
            $row->deleteMetadata('idsubdatatable_in_db');

            // use default row to ensure column ordering and add missing columns/aggregate cut-off columns
            $orderedColumns = $defaultRow;
            foreach ($row->getColumns() as $name => $value) {
                if (isset($orderedColumns[$name])) {
                    $orderedColumns[$name] = $value;
                } else {
                    $orderedColumns[$others] += $value;
                }
            }
            $row->setColumns($orderedColumns);
        }

        $table->clearQueuedFilters(); // TODO: shouldn't clear queued filters, but we can't wait for them to be run
                                      //       since generic filters are run before them. remove after refactoring
                                      //       processed metrics.

        // prepend numerals to columns in a queued filter (this way, disable_queued_filters can be used
        // to get machine readable data from the API if needed)
        $prependedColumnNames = $this->getOrderedColumnsWithPrependedNumerals($defaultRow, $others);

        Log::debug("PivotByDimension::%s: prepended column name mapping: %s", __FUNCTION__, $prependedColumnNames);

        $table->queueFilter(function (DataTable $table) use ($prependedColumnNames) {
            foreach ($table->getRows() as $row) {
                $row->setColumns(array_combine($prependedColumnNames, $row->getColumns()));
            }
        });
    }
731526
public function removeEvent($event, $table = null): void
    {
        unset($this->events[$table ?? static::TABLE_ANY][$event]);
    }
1371186
protected function setEmptyNullablesToNull(array $values): array
	{
		$nullables = $this->getNullableColumns();

		foreach($values as $column => $value)
		{
			if($value === '' && in_array($column, $nullables))
			{
				$values[$column] = null;
			}
		}

		return $values;
	}
891692
public function removeTable($table)
    {
        if ($table instanceof Table)
            $table = $table->getName();
        $this->tables->set('tables', $table, null);
        return $this;
    }
449111
public function initialize(Table $table)
    {
        $this->table = $table;
        $this->table->setData($this->getData());
    }
716141
public function drop($table)
    {
        $blueprint = $this->createBlueprint($table);

        $blueprint->drop();

        $this->build($blueprint);
    }
1278055
public function initDbTable($table = null) {
		if (empty($table)) {
			return false;
		}

		$initModel = ClassRegistry::init(Inflector::classify($table), true);
		if ($initModel === false) {
			return false;
		}

		if (!method_exists($initModel, 'initDbTable')) {
			return false;
		}

		$ds = $initModel->getDataSource();
		if (!$ds->truncate($initModel)) {
			return false;
		}

		return $initModel->initDbTable();
	}
693400
public function assertTableExists(string $table): void
    {
        if ($this->conn->getSchemaManager()->tablesExist([$table]) === false) {
            throw new NeuralyzerException("Table $table does not exist");
        }
    }
792490
public function dropIfExists($table)
    {
        $blueprint = $this->createBlueprint($table);

        $blueprint->dropIfExists();

        $this->build($blueprint);
    }
29974
protected function setNullableFields()
    {
        foreach ($this->nullableFromArray($this->getAttributes()) as $key => $value) {
            $this->attributes[$key] = $this->nullIfEmpty($value, $key);
        }
    }
996321
public function from($table, $columns = null)
    {
        $this->table($table);
        if( !empty($columns) ) {
            $this->columns($columns);
        }
        return $this;
    }