Dodaje dane do tabel

@return void
777292
public function run()
    {

        DB::beginTransaction();
        try {
            $this->down();
            $this->addNotification([
                'category' => 'default',
                'severity' => 'medium',
                'event'    => 'notification.user_has_been_created',
                'contents' => [
                    'en' => [
                        'title'   => 'User has been created',
                        'content' => 'User [[ user.firstname ]] [[ user.lastname ]] has been created.'
                    ],
                ]
            ]);
            $this->addNotification([
                'category' => 'default',
                'severity' => 'high',
                'event'    => 'notification.user_has_not_been_created',
                'contents' => [
                    'en' => [
                        'title'   => 'User has not been created',
                        'content' => 'User [[ user.firstname ]] [[ user.lastname ]] has not been created.'
                    ],
                ]
            ]);
            $this->addNotification([
                'category' => 'default',
                'severity' => 'medium',
                'event'    => 'notification.user_has_been_deleted',
                'contents' => [
                    'en' => [
                        'title'   => 'User has been deleted',
                        'content' => 'User [[ user.firstname ]] [[ user.lastname ]] has been deleted.'
                    ],
                ]
            ]);
            $this->addNotification([
                'category' => 'default',
                'severity' => 'high',
                'event'    => 'notification.user_has_not_been_deleted',
                'contents' => [
                    'en' => [
                        'title'   => 'User has not been deleted',
                        'content' => 'User [[ user.firstname ]] [[ user.lastname ]] has not been deleted.'
                    ],
                ]
            ]);
            $this->addNotification([
                'category' => 'default',
                'severity' => 'medium',
                'event'    => 'notification.user_has_been_updated',
                'contents' => [
                    'en' => [
                        'title'   => 'User has been updated',
                        'content' => 'User [[ user.firstname ]] [[ user.lastname ]] has been updated.'
                    ],
                ]
            ]);
            $this->addNotification([
                'category' => 'default',
                'severity' => 'high',
                'event'    => 'notification.user_has_not_been_updated',
                'contents' => [
                    'en' => [
                        'title'   => 'User has not been updated',
                        'content' => 'User [[ user.firstname ]] [[ user.lastname ]] has not been updated.'
                    ],
                ]
            ]);
        } catch (Exception $ex) {
            DB::rollback();
            throw $ex;
        }

        DB::commit();
    }
1098423
protected function _mysql()
	{
		$this->_msg(sprintf('Adding label and status columns'), 0);
		$this->_status( '' );

		foreach ($this->_mysql as $table => $columns) {

			if ($this->_schema->tableExists($table)) {

				foreach ($columns as $column => $stmt) {

					$this->_msg(sprintf('Checking column "%1$s.%2$s": ', $table, $column), 1);

					if (!$this->_schema->columnExists($table, $column)) {
						$this->_execute($stmt);
						$this->_status('added');
					} else {
						$this->_status('OK');
					}
				}
			}
		}
	}
709525
protected function init() {
        $this->data['crud'] = 'c';
        $this->data['edulevel'] = self::LEVEL_OTHER;
        $this->data['objecttable'] = competency::TABLE;
    }
3886
protected function _mysql()
	{
		$this->_msg(sprintf('Setting label and status values'), 0);
		$this->_status( '' );

		foreach ($this->_mysql as $table => $stmts)
		{
			$this->_msg(sprintf('Checking table "%1$s": ', $table), 1);

			if ($this->_schema->tableExists($table)) {
				$this->_executeList($stmts);
				$this->_status('OK');
			} else {
				$this->_status('n/a');
			}
		}
	}
1288597
public function run()
    {
        DB::table('languages')->delete();

        foreach ($this->langs() as $lang) {
            Language::create($lang);
        }
    }
124978
public function actionDrop()
    {
        $stdout = '';
        foreach ($this->db->schema->getTableSchemas() as $table) {
            if ($table->name === $this->migrationTable) {
                continue;
            }
            $stdout .= static::generateDropTable($table->name);
            if (!empty($table->foreignKeys)) {
                $stdout .= ' // fk: ';

                foreach ($table->foreignKeys as $fk) {
                    foreach ($fk as $k => $v) {
                        if (0 === $k) {
                            continue;
                        }
                        $stdout .= "$k, ";
                    }
                }
                $stdout = rtrim($stdout, ', ');
            }
            $stdout .= "\n";
        }
        $this->stdout($stdout);
    }
318852
protected function runSoftDelete()
    {
        $query = $this->setKeysForSaveQuery($this->newModelQuery());

        $time = $this->freshTimestamp();

        $columns = [$this->getDeletedAtColumn() => $this->fromDateTime($time)];

        $this->{$this->getDeletedAtColumn()} = $time;

        if ($this->timestamps && ! is_null($this->getUpdatedAtColumn())) {
            $this->{$this->getUpdatedAtColumn()} = $time;

            $columns[$this->getUpdatedAtColumn()] = $this->fromDateTime($time);
        }

        $query->update($columns);
    }
408053
protected function runSoftDelete()
    {
        $query = $this->newQueryWithoutScopes()->where($this->getKeyName(), $this->getKey());

        $this->{$this->getDeletedAtColumn()} = $time = $this->freshTimestamp();

        $query->update([$this->getDeletedAtColumn() => $this->fromDateTime($time)]);
    }
185741
public function change()
    {
        $tableName = 'language_translations';
        if (!$this->hasTable($tableName)) {
            $tableName = 'translations';
        }

        $table = $this->table($tableName);
        if ($table->hasColumn('is_active')) {
            $table->changeColumn('is_active', 'boolean', [
                'default' => true,
                'null' => true,
            ]);
        }
        $table->update();
    }
340195
private function execute()
    {
        $this->Connect();
        try {
            $this->delete->execute($this->places);
            $this->result = true;
        } catch (\PDOException $e) {
            $this->result = null;
            $this->erro = "<b>Erro ao Deletar:</b> {$e->getMessage()}";
        }

        parent::setDefault();
    }
608976
public function actionCreate()
    {
        $stdout = '';
        foreach ($this->db->schema->getTableSchemas() as $table) {
            if ($table->name === $this->migrationTable) {
                continue;
            }
            $stdout .= static::generateCreateTable($table->name).
                static::generateColumns($table->columns, $this->db->schema->findUniqueIndexes($table)).
                static::generatePrimaryKey($table->primaryKey, $table->columns).
                static::generateTableOptions();
        }
        foreach ($this->db->schema->getTableSchemas() as $table) {
            $stdout .= $this->generateForeignKey($table);
        }
        $this->stdout($stdout);
    }
818841
protected function createTable()
    {
        $template = file_get_contents(dirname(__FILE__) . '/TableSchema.sql');
        $this->pdo->query(sprintf($template, $this->table));
    }
711546
public function __HANDLER()
    {
        // Create query to get users
        $query = dbQuery('user')->Active(1)->order_by('UserID');

        // Create generic table for users
        $table = new Table($query);

        // Установим представление
        m()->view('main/index')->title(t('Пользователи системы', true))
            ->all_materials(true)
            // Установим шаблон таблицы пользователей
            ->user_table($table->render());
    }
284672
public function table()
    {
        $testsPerCol = 25;
        $count       = count($this->runner->tests);

        $line_width = $this->getLineWidth();

        switch (true) {
            case $line_width <= 50:
                $testsPerCol = 10;
                break;
            case $line_width <= 70:
                $testsPerCol = 15;
                break;
            case $line_width <= 80:
                $testsPerCol = 20;
                break;
            case $line_width > 100:
                $testsPerCol = 50;
                break;
            case $line_width > 50 && $line_width <= 100:
            default:
                $testsPerCol = 25;
                break;
        }

        echo '  ';
        $this->x = 2;
        $this->y = 0;
        foreach ($this->runner->tests as $i => $test) {
            $test->setPosition($this->x, $this->y);
            echo $this->gray('◼ ');
            $this->x += 2;

            $j = $i + 1;
            if (($j % ($testsPerCol * 4)) === 0) {
                echo "  $j";
            }
            if (($j % $testsPerCol) === 0 & $j !== $count) {
                echo "\n  ";
                $this->y += 1;
                $this->x = 2;
            }
        }

        echo "\n";
        $this->y++;
        $this->x = 0;

        $this->xMax = $this->x;
        $this->yMax = $this->y;
        $this->goToXY($this->xMax, $this->yMax);
    }
1161902
private function checkInsert() {
            if (!isset($this->data["allowInsert"])) return false;
            if (!(null !== URLParser::v($this->data["uid"] . "___INSERT"))) return false;
            if (!isset($this->data["table"])) return $this->merged;
            if (isset($this->data["rights"])) {
                if (isset($this->data["rights"]["insert"]) && $this->data["rights"]["insert"]) { // ak sa vyzaduju prava na vkladanie, tak ich over
                    if (Group::exists($this->data["rights"]["insert"])) { // ak existuje dane id skupiny
                        if (!Group::isInGroupId($this->data["rights"]["insert"])) return false;
                    } else { // inak existuje nazov skupiny
                        if (!Group::userInGroup($this->data["rights"]["insert"])) return false;
                    }
                } else {
                    if (@$this->data["rights"]["insert"]) return false;
                }
            }
            $formName = $this->data["uid"];
            if (isset($this->data["execute"])) {
                if (isset($this->data["execute"]["beforeInsert"])) {
                    try {
                        if (!$this->execute($this->data["execute"]["beforeInsert"])) {
                            return false;
                        }
                    }
                    catch(\Exception $exc) {
                        $this->exception = $exc;
                        throw $exc;
                    }
                }
            }
            $data = array();
            $includedCols = array();
            $this->updateLangs = $langupdates = array();
            foreach ($this->data["col"] as $colname => $item) {
                if (isset($item["data"]["type"])) $item["data"]["datatype"] = $item["data"]["type"];
                $usg = "MFi";
                if (isset($item["usage"]) && ((isset($item["usage"][$usg]) && $item["usage"][$usg]) || in_array($usg, $item["usage"]))) {
                } else {
                    continue;
                }
                if (is_numeric($colname) && !isset($item["data"]["col"])) continue;
                if (isset($item["data"]["col"])) $colname = $item["data"]["col"];
                $n = $formName . "_" . $colname;
                if (isset($item["data"]["var"])) $n = $item["data"]["var"];
                $colValue = URLParser::v($n);
                if ($in = $this->inWhere($colname)) {
                    $colValue = $in["value"];
                    $item["editable"] = false;
                }
                $name1 = $n; //."__MF_";
                if (isset($item["data"]["datatype"])) {
                    $datatype = $item["data"]["datatype"];
                } else {
                    $datatype = "string";
                }
                if (!(null !== URLParser::v($name1)) && (null !== URLParser::v($n))) $colValue = URLParser::v($n);
                if ($item["form"]["type"] == "part") continue;
                if (isset($item["function"])) continue;
                // skontroluj format..
                if (@$includedCols[$colname]) {
                    continue;
                } else {
                    $includedCols[$colname] = true;
                }
                if (isset($item["editable"]) && $item["editable"] == false && isset($item["texts"]["default"])) {
                    $data[$colname] = $this->getText($item["texts"]["default"]);
                    continue;
                } else {
                    if (isset($item["editable"]) && !$item["editable"]) {
                        continue;
                    }
                }
                if (!isset($item["FormItemInstance"])) {
                    if (!self::$ItemsMap) {
                        self::MakeItemsMap();
                    }
                    if (!isset(self::$ItemsMap[$item["form"]["type"]])) {
                        throw new \Exception(Language::get("Form type %formtype% has not been found!", array("%formtype%" => $item["form"]["type"])));
                    }
                    $item["FormItemInstance"] = new self::$ItemsMap[$item["form"]["type"]]($item, $this->data);
                }
                if ($item["FormItemInstance"]->IsDictionary()) {
                    $langupdates[$colname] = $item["FormItemInstance"]->Validate($name1);
                    $langupdates[$colname] = $this->filters($data[$colname], $datatype, true);
                } else {
                    $data[$colname] = $item["FormItemInstance"]->Validate($name1);
                    $data[$colname] = $this->filters($data[$colname], $datatype, true);
                }
                try {
                    $this->checkRightDataFormat($item, $name1);
                }
                catch(\Exception $e) {
                    throw $e;
                }
            }
            $this->updateLangs = $langupdates;
            foreach ($this->where as $col => $val) {
                if (is_array($val)) {
                    if ($val["op"] == "eq") {
                        $data[$val["col"]] = $val["value"];
                    }
                } else {
                    $data[$col] = $val;
                }
            }
            $this->insertData = $data;
            if ($this->merged) {
                return true;
            } else {
                return $this->doInsert();
            }
        }
705595
public function execute()
    {

        $this->query("DELETE FROM `{{NAILS_DB_PREFIX}}app_setting` WHERE `grouping` = 'email' and `key` != 'from_name' and `key` != 'from_email';");
        /**
         * Convert admin changelog data into JSON strings rather than use serialize
         */

        $oResult = $this->query('SELECT id, email_vars FROM {{NAILS_DB_PREFIX}}email_archive');
        while ($oRow = $oResult->fetch(\PDO::FETCH_OBJ)) {

            $mOldValue = unserialize($oRow->email_vars);
            $sNewValue = json_encode($mOldValue);

            //  Update the record
            $sQuery = '
                UPDATE `{{NAILS_DB_PREFIX}}email_archive`
                SET
                    `email_vars` = :newValue
                WHERE
                    `id` = :id
            ';

            $oSth = $this->prepare($sQuery);

            $oSth->bindParam(':newValue', $sNewValue, \PDO::PARAM_STR);
            $oSth->bindParam(':id', $oRow->id, \PDO::PARAM_INT);

            $oSth->execute();
        }
    }
355557
public function main()
    {
        $options = (array)$this->params;
        $destination = normalizePath("{$options['destination']}/");

        if (is_string($options['tables'])) {
            $options['tables'] = explode(',', $options['tables']);
        }

        if (is_string($options['no-data'])) {
            $options['no-data'] = explode(',', $options['no-data']);
        }

        if (file_exists($destination)) {
            $dst = new Folder($destination);
            $dst->delete();
            $this->out(__d('system', 'Removing existing directory: {0}', $destination), 1, Shell::VERBOSE);
        } else {
            new Folder($destination, true);
            $this->out(__d('system', 'Creating directory: {0}', $destination), 1, Shell::VERBOSE);
        }

        $db = ConnectionManager::get('default');
        $db->connect();
        $schemaCollection = $db->schemaCollection();
        $tables = $schemaCollection->listTables();

        foreach ($tables as $table) {
            if (!empty($options['tables']) && !in_array($table, $options['tables'])) {
                $this->out(__d('system', 'Table "{0}" skipped', $table), 1, Shell::VERBOSE);
                continue;
            }

            $Table = TableRegistry::get($table);
            $Table->behaviors()->reset();
            $fields = [
                '_constraints' => [],
                '_indexes' => [],
                '_options' => (array)$Table->schema()->options(),
            ];
            $columns = $Table->schema()->columns();
            $records = [];
            $primaryKeys = [];

            foreach ($Table->schema()->indexes() as $indexName) {
                $index = $Table->schema()->index($indexName);
                if (!empty($index['columns'])) {
                    $fields['_indexes']["{$table}_{$indexName}_index"] = $index;
                }
            }

            foreach ($columns as $column) {
                $fields[$column] = $Table->schema()->column($column);
            }

            foreach ($Table->schema()->constraints() as $constraint) {
                $constraintName = in_array($constraint, $columns) ? Inflector::underscore("{$table}_{$constraint}") : $constraint;
                $fields['_constraints'][$constraintName] = $Table->schema()->constraint($constraint);
                if (isset($fields['_constraints']['primary']['columns'])) {
                    $primaryKeys = $fields['_constraints']['primary']['columns'];
                }
            }

            foreach ($fields as $column => $info) {
                if (isset($info['length']) &&
                    in_array($column, $primaryKeys) &&
                    isset($info['autoIncrement']) &&
                    $info['autoIncrement'] === true
                ) {
                    unset($fields[$column]['length']);
                }
            }

            // FIX: We need RAW data for time instead of Time Objects
            $originalTypes = [];
            foreach ($Table->schema()->columns() as $column) {
                $type = $Table->schema()->columnType($column);
                $originalTypes[$column] = $type;
                if (in_array($type, ['date', 'datetime', 'time'])) {
                    $Table->schema()->columnType($column, 'string');
                }
            }

            if ($options['mode'] === 'full') {
                foreach ($Table->find('all') as $row) {
                    $row = $row->toArray();
                    if ($this->params['no-id'] && isset($row['id'])) {
                        unset($row['id']);
                    }
                    $records[] = $row;
                }
            }

            $className = Inflector::camelize($table) . 'Fixture';
            if ($options['fixture'] && in_array($className, ['AcosFixture', 'UsersFixture'])) {
                $records = [];
            }

            // undo changes made by "FIX"
            foreach ($originalTypes as $column => $type) {
                $fields[$column]['type'] = $type;
            }

            if (empty($fields['_indexes'])) {
                unset($fields['_indexes']);
            }

            $fields = $this->_arrayToString($fields);
            $records = in_array($table, $options['no-data']) ? '[]' : $this->_arrayToString($records);

            $fixture = $this->_classFileHeader($className);
            $fixture .= "{\n";
            $fixture .= "\n";
            $fixture .= "    /**\n";
            $fixture .= "     * Table name.\n";
            $fixture .= "     *\n";
            $fixture .= "     * @var string\n";
            $fixture .= "     */\n";
            $fixture .= "    public \$table = '{$table}';\n";
            $fixture .= "\n";
            $fixture .= "    /**\n";
            $fixture .= "     * Table columns.\n";
            $fixture .= "     *\n";
            $fixture .= "     * @var array\n";
            $fixture .= "     */\n";
            $fixture .= "    public \$fields = {$fields};\n";
            $fixture .= "\n";
            $fixture .= "    /**\n";
            $fixture .= "     * Table records.\n";
            $fixture .= "     *\n";
            $fixture .= "     * @var array\n";
            $fixture .= "     */\n";
            $fixture .= "    public \$records = {$records};\n";
            $fixture .= "}\n";

            $file = new File(normalizePath("{$destination}/{$className}.php"), true);
            $file->write($fixture, 'w', true);
            $this->out(__d('system', 'Table "{0}" exported!', $table), 1, Shell::VERBOSE);
        }

        $this->out(__d('system', 'Database exported to: {0}', $destination));

        return true;
    }