(non-PHPdoc)
@see PAGI\Client.IClient::databaseDel()
3473
public function databaseDel($family, $key)
    {
        $cmd = implode(
            ' ',
            array(
                'DATABASE', 'DELTREE', '"' . $family. '"', '"' . $key . '"'
            )
        );
        $result = $this->send($cmd);
        if ($result->isResult(0)) {
            throw new DatabaseInvalidEntryException('Invalid family or key.');
        }
    }
1319030
protected function buildModel($model)
    {
        try {
            $query = $this->resolveQueryBuilderFromModel($model);
        } catch (InvalidArgumentException $e) {
            $query = $model;
        }

        if ($this->paginate === true && \method_exists($query, 'paginate')) {
            $query = $query->paginate($this->perPage, ['*'], $this->pageName);
        } elseif ($this->isQueryBuilder($query)) {
            $query = $query->get();
        }

        return $query;
    }
280575
public function generate($className, $db = null)
    {
        /** @var \yii\db\ActiveRecord|\DevGroup\DataStructure\traits\PropertiesTrait $className */
        $this->setDb($db);

        $tableOptions = $this->db->driverName === 'mysql'
            ? 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'
            : null;

        // Static values
        $staticValuesTable = $className::staticValuesBindingsTable();

        $this->createTable(
            $staticValuesTable,
            [
                'model_id' => $this->integer()->notNull(),
                'static_value_id' => $this->integer()->notNull(),
                'sort_order' => $this->integer()->notNull()->defaultValue(0),
            ],
            $tableOptions
        );

        $this->addPrimaryKey('uniquePair', $staticValuesTable, ['model_id', 'static_value_id']);
        $this->addForeignKey(
            'fk'.crc32($className).'SV',
            $staticValuesTable,
            ['model_id'],
            $className::tableName(),
            ['id'],
            'CASCADE'
        );
        $this->addForeignKey(
            static::getForeignKeyName($staticValuesTable, StaticValue::tableName(), $this->db),
            $staticValuesTable,
            'static_value_id',
            StaticValue::tableName(),
            'id',
            'CASCADE',
            'CASCADE'
        );

        // eav!
        $eavTable = $className::eavTable();
        $this->createTable(
            $eavTable,
            [
                'id' => $this->primaryKey(),
                'model_id' => $this->integer()->notNull(),
                'property_id' => $this->integer()->notNull(),
                'sort_order' => $this->integer()->notNull()->defaultValue(0),
                'value_integer' => $this->integer(),
                'value_float' => $this->float(),
                'value_string' => $this->string(),
                'value_text' => $this->text(),
                'language_id' => $this->integer()->notNull()->defaultValue(0),
            ],
            $tableOptions
        );
        $this->createIndex(
            'model_properties',
            $eavTable,
            [
                'model_id',
                'sort_order',
            ]
        );
        $this->addForeignKey(
            'fk'.crc32($className).'Eav',
            $eavTable,
            ['model_id'],
            $className::tableName(),
            ['id'],
            'CASCADE'
        );
        $this->addForeignKey(
            static::getForeignKeyName($eavTable, Property::tableName(), $this->db),
            $eavTable,
            'property_id',
            Property::tableName(),
            'id',
            'CASCADE',
            'CASCADE'
        );

        // table inheritance
        $tableInheritanceTable = $className::tableInheritanceTable();
        $this->createTable(
            $tableInheritanceTable,
            [
                'model_id' => $this->primaryKey(),
            ],
            $tableOptions
        );
        $this->addForeignKey(
            'fk'.crc32($className).'TI',
            $tableInheritanceTable,
            ['model_id'],
            $className::tableName(),
            ['id'],
            'CASCADE'
        );

        // binded property groups
        $bindedGroupsTable = $className::bindedPropertyGroupsTable();
        $this->createTable(
            $bindedGroupsTable,
            [
                'model_id' => $this->integer()->notNull(),
                'property_group_id' => $this->integer()->notNull(),
                'sort_order' => $this->integer()->notNull()->defaultValue(0),
            ],
            $tableOptions
        );
        $this->createIndex(
            'uniquePair',
            $bindedGroupsTable,
            [
                'model_id',
                'property_group_id',
            ],
            true
        );
        $this->addForeignKey(
            'fk'.crc32($className).'BPG',
            $bindedGroupsTable,
            ['model_id'],
            $className::tableName(),
            ['id'],
            'CASCADE'
        );
        $this->addForeignKey(
            'fk'.crc32($className).'BPG1',
            $bindedGroupsTable,
            ['property_group_id'],
            PropertyGroup::tableName(),
            ['id'],
            'CASCADE'
        );
        $this->insert(
            ApplicablePropertyModels::tableName(),
            [
                'class_name' => $className,
                'name' => substr($className, strrpos($className, '\\') + 1),
            ]
        );
    }
100469
public function createCommand($db = null)
    {
        if ($this->primaryModel !== null) {
            // lazy loading
            if (is_array($this->via)) {
                // via relation
                /* @var $viaQuery ActiveQuery */
                list($viaName, $viaQuery) = $this->via;
                if ($viaQuery->multiple) {
                    $viaModels = $viaQuery->all();
                    $this->primaryModel->populateRelation($viaName, $viaModels);
                } else {
                    $model = $viaQuery->one();
                    $this->primaryModel->populateRelation($viaName, $model);
                    $viaModels = $model === null ? [] : [$model];
                }
                $this->filterByModels($viaModels);
            } else {
                $this->filterByModels([$this->primaryModel]);
            }
        }

        /* @var $modelClass ActiveRecord */
        $modelClass = $this->modelClass;
        if ($db === null) {
            $db = $modelClass::getDb();
        }

        if ($this->type === null) {
            $this->type = $modelClass::type();
        }
        if ($this->index === null) {
            $this->index = $modelClass::index();
            $this->type = $modelClass::type();
        }
        $commandConfig = $db->getQueryBuilder()->build($this);

        return $db->createCommand($commandConfig);
    }
166907
public function setDatabase($dbname)
    {
        $this->config->setDatabase($dbname);
        if ($this->connection) {
            try {
                $this->query('USE ' . $this->quote()->identifier($dbname));
            } catch (RuntimeException $exception) {
                /** @var \PDOException $prevException */
                $prevException = $exception->getPrevious();
                if (UnknownDatabaseException::isUnknownDatabase($prevException)) {
                    throw UnknownDatabaseException::createFromUnknownDatabase($dbname, $prevException);
                }

                throw $exception;
            }
        }

        return $this;
    }
162543
protected function loadModel($id = null)
	{
		/** @var BaseActiveRecord $modelClass */
		$modelClass = $this->modelClass();
		if($id) {
			$this->modelInstance = $modelClass::findOne($id);
		} else {
			$this->modelInstance = new $modelClass();
		}
		$this->modelInstance->load($this->attributes, '');
		return $this->modelInstance;
	}
1192333
public function getByID($id)
    {
        $pkey = $this->getPrimaryKey();
        if ($pkey === null)
            throw new DAOException("A primary key is required to select a record by ID");

        // If there's a unary primary key, the value can be specified as a
        // single scalar, rather than an array
        if (count($pkey) === 1 && is_scalar($id))
            foreach ($pkey as $colname => $def)
                $id = [$colname => $id];


        $condition = $this->getSelector($pkey, $id);
        $rec = $this->fetchSingle(QB::where($condition));
        if (empty($rec))
            throw new DAOEXception("Object not found with " . WF::str($id));

        $model = new $this->model_class;
        $model->assignRecord($rec, $this->db);
        return $model;
    }
724580
public function createDatabase($domainName, \Transip\Model\Db $db)
    {
        return $this->getSoapClient(array_merge(array($domainName, $db), array('__method' => 'createDatabase')))->createDatabase($domainName, $db);
    }
605600
private function model($insert = false)
    {
        $model = $this->model;

        if ($insert === false) {
            foreach ($this->extraColumns as $key => $value) {
                $model->where($key, $value);
            }
        }

        if ($this->hasConstraint()) {
            /** @var  Closure  $callback */
            $callback = $this->queryConstraint;
            $model    = $callback($model, $insert);
        }

        return $model;
    }
851180
public function insert(&$model)
    {
        $is_model = is_a($model, $this->model_class);
        if (!is_array($model) && !$is_model)
            throw new InvalidTypeException("An array or a instance of {$this->model_class} should be provided");

        $record = $is_model ? $model->getRecord() : $model;
        $db_record = array();
        $table = $this->table;
        $columns = $table->getColumns();

        foreach ($columns as $field => $def)
        {
            if (!isset($record[$field]) && !$def->isNullable() && $def->getDefault() === null && !$def->getSerial())
                throw new InvalidValueException("Column must not be null: {$field}");
        }

        foreach ($record as $field => $value)
        {
            if (!isset($columns[$field]))
                throw new DAOException("Invalid field: " . $field);

            $coldef = $columns[$field];
            $db_record[$field] = $coldef->beforeInsertFilter($value);
        }


        $pkey = $table->getPrimaryColumns();
        if ($pkey === null)
            $pkey = [];
        $insert = new Query\Insert($this->tablename, $db_record, $pkey);

        $drv = $this->db->getDriver();
        $drv->insert($insert, $pkey);
            
        // Store the potentially generated serial in the inserted record
        $pkey_values = $insert->getInsertId();
        foreach ($pkey as $pkey_column)
        {
            if (!$pkey_column->getSerial())
                continue;

            $colname = $pkey_column->getName();
            if (!isset($pkey_values[$colname]))
                throw new DAOException("No value generated for serial column {$colname}");

            if ($is_model)
                $model->setField($colname, (int)$pkey_values[$colname]);
            else
                $model[$colname] = (int)$pkey_values[$colname];
        }

        if ($is_model)
        {
            $model->markClean();
            $model->setSourceDB($this->db);
        }

        return $pkey_values;
    }
190802
public function addDatabase($db)
    {
        if ($db instanceof Database) {
            $db->setAppData($this);
            if ($db->getPlatform() === null) {
                if ($config = $this->getGeneratorConfig()) {
                    $pf = $config->getConfiguredPlatform(null, $db->getName());
                    $db->setPlatform($pf ? $pf : $this->platform);
                } else {
                    $db->setPlatform($this->platform);
                }
            }
            $this->dbList[] = $db;

            return $db;
        } else {
            // XML attributes array / hash
            $d = new Database();
            $d->setAppData($this);
            $d->loadFromXML($db);

            return $this->addDatabase($d); // calls self w/ different param type
        }
    }
356092
public function getModel()
    {
        $namePath = $this->getModelClass();
        $model = new $namePath();

        if (!($model instanceof EntityDataModel)) {
            throw new \Exception($this->valueClass.' is not an instance of EntityModel.');
        }

        return $model;
    }
363603
public function getModifyDatabaseDDL(PropelDatabaseDiff $databaseDiff)
    {
        $ret = $this->getBeginDDL();

        foreach ($databaseDiff->getRemovedTables() as $table) {
            $ret .= $this->getDropTableDDL($table);
        }

        foreach ($databaseDiff->getRenamedTables() as $fromTableName => $toTableName) {
            $ret .= $this->getRenameTableDDL($fromTableName, $toTableName);
        }

        foreach ($databaseDiff->getAddedTables() as $table) {
            $ret .= $this->getAddTableDDL($table);
            $ret .= $this->getAddIndicesDDL($table);
        }

        foreach ($databaseDiff->getModifiedTables() as $tableDiff) {
            $ret .= $this->getModifyTableDDL($tableDiff);
        }

        foreach ($databaseDiff->getAddedTables() as $table) {
            $ret .= $this->getAddForeignKeysDDL($table);
        }

        $ret .= $this->getEndDDL();

        return $ret;
    }
1305441
private function registerDatabaseProvider() {
        $this->app->bind(\BackupManager\Databases\DatabaseProvider::class, function ($app) {
            $provider = new Databases\DatabaseProvider($this->getDatabaseConfig($app['config']['database.connections']));
            $provider->add(new Databases\MysqlDatabase);
            $provider->add(new Databases\PostgresqlDatabase);
            return $provider;
        });
    }
824211
public function setDbName( ?string $dbName ) : PgSQL
   {

      if ( ! $this->_supportedAttributes->get( 'dbname' )->validateValue( $dbName ) )
      {
         throw new ArgumentException( 'dbname', $dbName, 'Invalid database name!' );
      }

      $this->_attributes[ 'dbname' ] = $dbName;

      return $this;

   }
921070
public function refSQL()
    {
        /** @type SQL_Model $q */
        $q = $this->ref('model');
        $q->addCondition($q->id_field, $this);

        return $q;
    }
916392
protected function db(): Database
    {
        $conn = app(Pool::class)->getConnection();
        $database = $conn->defaultDatabase;

        return $conn->getRawConnection()->$database;
    }