INIT Indexing DB
@param \PDO $db
770690
public function initIndexing(\PDO $db)
    {

        // delete everything before reset indexing
        $dir = opendir($this->SqliteDir);
        while ($file = readdir($dir)) {
            if ($file != '.' && $file != '..' && $file != 'indexing' && $file != 'dbfastcache') {
                unlink($this->SqliteDir . '/' . $file);
            }
        }

        $db->exec('DROP TABLE if exists "balancing"');
        $db->exec('CREATE TABLE "balancing" ("keyword" VARCHAR PRIMARY KEY NOT NULL UNIQUE, "db" INTEGER)');
        $db->exec('CREATE INDEX "db" ON "balancing" ("db")');
        $db->exec('CREATE UNIQUE INDEX "lookup" ON "balancing" ("keyword")');

    }
1095289
function addIndex( $attributes ) {
		$name = strtoupper( $attributes['NAME'] );
		$this->indexes[$name] = new dbIndex( $this, $attributes );
		return $this->indexes[$name];
	}
192661
protected function connectToDb()
    {
        try {
            $this->db = new PDO("mysql:dbname=;" . $this->db_host, $this->db_user, $this->db_pass);
            $this->db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
        } catch (\Exception $e) {
            $this->log("Cannot connect to database.  Are the credentials correct?");
            $this->log(print_r($e), 1);
            exit;
        }
    }
1318438
protected function init()
    {
        if (null === $this->items) {
            list($constraints, $sorting, $joins) = $this->translate($this->filter, $this->sorting);

            if (empty($constraints)) {
                $constraints = '';
            } else {
                $constraints = ' WHERE ' . implode(' AND ', $constraints);
            }

            if ($this->prefetch) {
                $this->initEntities($constraints, $this->makeJoins($joins), $this->makeOrderBy($sorting, $joins));
            } else {
                $this->initKeys($constraints, $this->makeJoins($joins), $this->makeOrderBy($sorting, $joins));
            }

            $this->rewind();
        }
    }
866837
public function doFinalInitialization()
    {
        if (!$this->isInitialized) {
            foreach ($this->databases as $database) {
                $database->doFinalInitialization();
            }
            $this->isInitialized = true;
        }
    }
803961
public function up(Database $db)
    {
        $collection = $db->createCollection($this->collection);

        // Remove index
        $collection->deleteIndex(['domain_1_locale_1_original_1']);

        /** @var array $translatable */
        foreach ($collection->find() as $translatable) {
            $id = $translatable['_id'];
            if (!ctype_xdigit($id)) {
                $newId = sha1($id);
                if ($collection->findOne(['_id' => $newId], ['id'])) {
                    $collection->remove(['_id' => $id]);
                } else {
                    $translatable['_id'] = $newId;
                    $collection->insert($translatable);
                    $collection->remove(['_id' => $id]);
                }
            }
        }
    }
1249605
public function initialize() : void
  {
    $connection = config('database.default');

    Accessor::$appRoot       = config('app.dir');
    UpstartConfig::$database = config("database.connections.{$connection}");

    if (!DB::start()) {
      $this->exception('Could not establish a database connection.');
    }

    $this->loadView();
  }
1035341
private function constructDatabase($db)
    {
        if (is_null($this->dbClass)) {
            if (is_array($db)) {
                if (array_keys($db) !== range(0, count($db) - 1)) {
                    $this->db = new Databases\AssociativeArray($db);
                } else {
                    $this->db = new Databases\NumericArray($db);
                }
            } elseif ($db instanceof \Illuminate\Support\Collection) {
                $this->db = new Databases\LaravelCollection($db);
            } elseif ($db instanceof \Illuminate\Database\Eloquent\Builder
                || $db instanceof \Illuminate\Database\Eloquent\Relations\Relation) {
                $this->db = new Databases\LaravelEloquent($db);
            } elseif (!is_object($db)) {
                throw new InvalidArgumentException('Database must be an object or array');
            } else {
                $class_name = get_class($db);

                throw new DomainException("Please add database class for handling $class_name objects");
            }
        } else {
            $this->db = new $dbClass($db);
        }
    }
425119
private function init() {
        global $DB;
        if (!$this->category = $this->get_current_category($this->cat)) {
            return;
        }
        if ($this->recurse) {
            $categoryids = question_categorylist($this->category->id);
        } else {
            $categoryids = array($this->category->id);
        }
        list($catidtest, $this->params) = $DB->get_in_or_equal($categoryids, SQL_PARAMS_NAMED, 'cat');
        $this->where = 'q.category ' . $catidtest;
    }
886129
public void init(BaseDatabase database, Record record)
    {
        super.init(database, record);
        m_iRow = -1;        // resultSet row 0 = First row.
        m_iEOFRow = Integer.MAX_VALUE;  // Last valid row.
        m_iLastOrder = -1;
    }
1313558
private function initialize()
    {
        $this->pdo->exec(
            'CREATE TABLE IF NOT EXISTS `'.$this->table.'` '
            .'(id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, channel VARCHAR(255), level INTEGER, message LONGTEXT, time INTEGER UNSIGNED, INDEX(channel) USING HASH, INDEX(level) USING HASH, INDEX(time) USING BTREE)'
        );

        //Read out actual columns
        $actualFields = array();
        $rs = $this->pdo->query('SELECT * FROM `'.$this->table.'` LIMIT 0');
        for ($i = 0; $i < $rs->columnCount(); $i++) {
            $col = $rs->getColumnMeta($i);
            $actualFields[] = $col['name'];
        }

        //Calculate changed entries
        $removedColumns = array_diff(
            $actualFields,
            $this->additionalFields,
            $this->defaultfields
        );
        $addedColumns = array_diff($this->additionalFields, $actualFields);

        //Remove columns
        if (!empty($removedColumns)) {
            foreach ($removedColumns as $c) {
                $this->pdo->exec('ALTER TABLE `'.$this->table.'` DROP `'.$c.'`;');
            }
        }

        //Add columns
        if (!empty($addedColumns)) {
            foreach ($addedColumns as $c) {
                $this->pdo->exec('ALTER TABLE `'.$this->table.'` add `'.$c.'` TEXT NULL DEFAULT NULL;');
            }
        }

        // merge default and additional field to one array
        $this->defaultfields = array_merge($this->defaultfields, $this->additionalFields);

        $this->initialized = true;
    }
443131
protected function _initDb()
    {
        // DATABASE CONNECTION
        $resource = $this->getPluginResource('db');
        if (! $resource) {
            // Do not throw error here. Error is throw in frontDispatchLoopStartup()
            // and no, you should not try to access the database in any earlier
            // code anyway.
            //
            // You are free to change this, but then you get an ugly error message on
            // the screen, while this way the ErrorController is used.
            return null;
        }
        $db = $resource->getDbAdapter();

        // Firebug
        if ($this->_startFirebird) {
            $profiler = new \Zend_Db_Profiler_Firebug(GEMS_PROJECT_NAME);
            $profiler->setEnabled(true);
            $db->setProfiler($profiler);
        }
        \Zend_Db_Table::setDefaultAdapter($db);

        \Zend_Registry::set('db', $db);

        return $db;
    }
1024036
public function initDatabase()
    {
        $this->call('migrate');

        if (Administrator::count() == 0) {
            $this->call('db:seed', ['--class' => \ShaoZeMing\Merchant\Auth\Database\AdminTablesSeeder::class]);
        }
    }
148990
public void init(DatabaseOwner databaseOwner, String strDbName, int iDatabaseType, Map<String, Object> properties)
    {
        super.init(databaseOwner, strDbName, iDatabaseType, properties);
        m_pDatabase = null;
    }
483239
public void init(PhysicalDatabaseParent pDatabaseOwner, String strDbName, char charPDatabaseType)
    {
        m_htTableList = new Hashtable<Object,PTable>();
        m_strDBName = strDbName;
        m_charPDatabaseType = charPDatabaseType;
        this.setPDatabaseParent(pDatabaseOwner);
    }
91524
public function init() {
        parent::init();
        $this->db = Instance::ensure($this->db, Connection::className());
        $this->db->getCollection($this->itemTable)->createIndex(['name' => 1], ['unique' => true]);
        $this->db->getCollection($this->ruleTable)->createIndex(['name' => 1], ['unique' => true]);
    }
938738
public function setSourceDB(DB $db)
    {
        if ($db === null)
            throw new \InvalidArgumentException("Source database must not be null");
        $this->_source_db = $db;
        return $this;
    }