public function indexing($keyword)
    {
        if ($this->indexing == null) {
            $tableCreated = false;
            if (!\file_exists($this->SqliteDir . '/indexing')) {
                $tableCreated = true;
            }

            $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE);
            $PDO->setAttribute(PDO::ATTR_ERRMODE,
                PDO::ERRMODE_EXCEPTION);

            if ($tableCreated) {
                $this->initIndexing($PDO);
            }
            $this->indexing = $PDO;
            unset($PDO);

            $stm = $this->indexing->prepare("SELECT MAX(`db`) as `db` FROM `balancing`");
            $stm->execute();
            $row = $stm->fetch(PDO::FETCH_ASSOC);
            if (!isset($row['db'])) {
                $db = 1;
            } elseif ($row['db'] <= 1) {
                $db = 1;
            } else {
                $db = $row['db'];
            }

            // check file size

            $size = \file_exists($this->SqliteDir . '/db' . $db) ? filesize($this->SqliteDir . '/db' . $db) : 1;
            $size = round($size / 1024 / 1024, 1);


            if ($size > $this->maxSize) {
                $db++;
            }
            $this->currentDB = $db;

        }

        // look for keyword
        $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1");
        $stm->execute([
            ':keyword' => $keyword,
        ]);
        $row = $stm->fetch(PDO::FETCH_ASSOC);
        if (isset($row['db']) && $row['db'] != '') {
            $db = $row['db'];
        } else {
            /*
             * Insert new to Indexing
             */
            $db = $this->currentDB;
            $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)");
            $stm->execute([
                ':keyword' => $keyword,
                ':db' => $db,
            ]);
        }

        return $db;
    }
public function indexing($keyword)
    {
        if ($this->indexing == null) {
            $tableCreated = false;
            if (!\file_exists($this->SqliteDir . '/indexing')) {
                $tableCreated = true;
            }

            $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE);
            $PDO->setAttribute(PDO::ATTR_ERRMODE,
                PDO::ERRMODE_EXCEPTION);

            if ($tableCreated) {
                $this->initIndexing($PDO);
            }
            $this->indexing = $PDO;
            unset($PDO);

            $stm = $this->indexing->prepare("SELECT MAX(`db`) as `db` FROM `balancing`");
            $stm->execute();
            $row = $stm->fetch(PDO::FETCH_ASSOC);
            if (!isset($row['db'])) {
                $db = 1;
            } elseif ($row['db'] <= 1) {
                $db = 1;
            } else {
                $db = $row['db'];
            }

            // check file size

            $size = \file_exists($this->SqliteDir . '/db' . $db) ? filesize($this->SqliteDir . '/db' . $db) : 1;
            $size = round($size / 1024 / 1024, 1);


            if ($size > $this->maxSize) {
                $db++;
            }
            $this->currentDB = $db;

        }

        // look for keyword
        $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1");
        $stm->execute([
            ':keyword' => $keyword,
        ]);
        $row = $stm->fetch(PDO::FETCH_ASSOC);
        if (isset($row['db']) && $row['db'] != '') {
            $db = $row['db'];
        } else {
            /*
             * Insert new to Indexing
             */
            $db = $this->currentDB;
            $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)");
            $stm->execute([
                ':keyword' => $keyword,
                ':db' => $db,
            ]);
        }

        return $db;
    }
public function indexing ( $ keyword ) { if ( $ this -> indexing == null ) { $ tableCreated = false ; if ( ! \ file_exists ( $ this -> SqliteDir . '/indexing' ) ) { $ tableCreated = true ; } $ PDO = new PDO ( "sqlite:" . $ this -> SqliteDir . '/' . self :: INDEXING_FILE ) ; $ PDO -> setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_EXCEPTION ) ; if ( $ tableCreated ) { $ this -> initIndexing ( $ PDO ) ; } $ this -> indexing = $ PDO ; unset ( $ PDO ) ; $ stm = $ this -> indexing -> prepare ( "SELECT MAX(`db`) as `db` FROM `balancing`" ) ; $ stm -> execute ( ) ; $ row = $ stm -> fetch ( PDO :: FETCH_ASSOC ) ; if ( ! isset ( $ row [ 'db' ] ) ) { $ db = 1 ; } elseif ( $ row [ 'db' ] <= 1 ) { $ db = 1 ; } else { $ db = $ row [ 'db' ] ; } // check file size $ size = \ file_exists ( $ this -> SqliteDir . '/db' . $ db ) ? filesize ( $ this -> SqliteDir . '/db' . $ db ) : 1 ; $ size = round ( $ size / 1024 / 1024 , 1 ) ; if ( $ size > $ this -> maxSize ) { $ db ++ ; } $ this -> currentDB = $ db ; } // look for keyword $ stm = $ this -> indexing -> prepare ( "SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1" ) ; $ stm -> execute ( [ ':keyword' => $ keyword , ] ) ; $ row = $ stm -> fetch ( PDO :: FETCH_ASSOC ) ; if ( isset ( $ row [ 'db' ] ) && $ row [ 'db' ] != '' ) { $ db = $ row [ 'db' ] ; } else { /*
             * Insert new to Indexing
             */ $ db = $ this -> currentDB ; $ stm = $ this -> indexing -> prepare ( "INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)" ) ; $ stm -> execute ( [ ':keyword' => $ keyword , ':db' => $ db , ] ) ; } return $ db ; }
INIT Instant DB
Return Database of Keyword
@param $keyword
@return int
INIT Instant DB Return Database of Keyword