prepare sql-statements for indexer
@return void
175206
public function prepareStatements()
    {
        $addUpdateQuery = '';
        $addInsertQueryFields = '';
        $addInsertQueryValues = '';

        // create vars to keep statements dynamic
        foreach ($this->additionalFields as $value) {
            $addUpdateQuery .= ', ' . $value . ' = ?';
            $addInsertQueryFields .= ', ' . $value;
            $addInsertQueryValues .= ', ?';
        }

        // Statement to check if record already exists in db
        $databaseConnection = Db::getDatabaseConnection('tx_kesearch_index');
        $databaseConnection->exec('PREPARE searchStmt FROM "
			SELECT *
			FROM tx_kesearch_index
			WHERE orig_uid = ?
			AND pid = ?
			AND type = ?
			AND language = ?
			LIMIT 1
		"');

        // Statement to update an existing record in indexer table
        $databaseConnection = Db::getDatabaseConnection('tx_kesearch_index');
        $databaseConnection->exec('PREPARE updateStmt FROM "
			UPDATE tx_kesearch_index
			SET pid=?,
			title=?,
			type=?,
			targetpid=?,
			content=?,
			tags=?,
			params=?,
			abstract=?,
			language=?,
			starttime=?,
			endtime=?,
			fe_group=?,
			tstamp=?' . $addUpdateQuery . '
			WHERE uid=?
		"');

        // Statement to insert a new records to index table
        $databaseConnection = Db::getDatabaseConnection('tx_kesearch_index');
        $databaseConnection->exec('PREPARE insertStmt FROM "
			INSERT INTO tx_kesearch_index
			(pid, title, type, targetpid, content, tags, params, abstract, language,'
            . ' starttime, endtime, fe_group, tstamp, crdate' . $addInsertQueryFields . ')
			VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?' . $addInsertQueryValues . ', ?)
		"');

        // disable keys only if indexer table was truncated (has 0 records)
        // this speeds up the first indexing process
        // don't use this for updating index table
        // if you activate this for updating 40.000 existing records, indexing process needs 1 hour longer
        $queryBuilder = Db::getQueryBuilder('tx_kesearch_index');
        $countIndex = $queryBuilder
            ->count('*')
            ->from('tx_kesearch_index')
            ->execute()
            ->fetchColumn(0);
        if ($countIndex == 0) {
            Db::getDatabaseConnection('tx_kesearch_index')->exec('ALTER TABLE tx_kesearch_index DISABLE KEYS');
        }
    }
405165
public function init()
    {

        // initialize the prepared statements
        $this->stockItemStmt =
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::STOCK_ITEM));
    }
687696
public function init()
    {

        // initialize the prepared statements
        $this->productVarcharsStmt =
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::PRODUCT_VARCHARS));
        $this->productVarcharByAttributeCodeAndEntityTypeIdAndStoreIdAndValueStmt =
                $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::PRODUCT_VARCHAR_BY_ATTRIBUTE_CODE_AND_ENTITY_TYPE_ID_AND_STORE_ID_AND_VALUE));
    }
517368
protected function _prepare($sql)
    {
        $connection = $this->_adapter->getConnection();

        $this->_stmt = sqlsrv_prepare($connection, $sql);

        if (!$this->_stmt) {
            // require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
            throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors());
        }

        $this->_originalSQL = $sql;
    }
431436
public function prepare()
    {
        if (null === $this->statement) {
            $this->statement = $this->db->prepare($this->getSql());
        }

        return $this;
    }
989470
protected function prepare_sql_courses() {
        global $DB;
        if (!preg_match('/\\%COURSEFILTER\\%/', $this->sql)) {
            return;
        }
        $this->init_course_access();
        $unaccessiblecourses = array_filter($this->courseaccess, function($item) {
            return !$item;
        });
        $idx = 0;
        while (preg_match('/^([^\\0]*?)\\%COURSEFILTER\\%([^\\0]*)$/', $this->sql, $matches)) {
            list($sql, $params) = $DB->get_in_or_equal(array_keys($unaccessiblecourses),
                    SQL_PARAMS_NAMED, 'ca_'.($idx++).'_', false, 0);
            $this->sql = $matches[1].' '.$sql.' '.$matches[2];
            $this->params += $params;
        }
    }
656064
protected function prepare()
    {
        $this
            ->getSession()
            ->getConnection()
            ->sendPrepareQuery(
                $this->getClientIdentifier(),
                $this->orderParameters($this->sql)
            );
        $this->is_prepared = true;

        return $this;
    }
513062
public function init()
    {

        // initialize the prepared statements
        $this->customerStmt =
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CUSTOMER));
        $this->customerByEmailAndWebsiteIdStmt =
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CUSTOMER_BY_EMAIL_AND_WEBSITE_ID));
        $this->customersStmt =
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CUSTOMERS));
    }
356071
function prepare($statement = null, array $placeholders = null) {
		$this->dbh !== null or $this->setup();

		if ($placeholders !== null) {
			$consts = [];
			foreach ($placeholders as $key => $val) {
				$consts["[$key]"] = $val;
			}

			return \fenrir\MysqlStatement::instance($this->dbh, strtr($statement, $consts));
		}
		else { // placeholders === null
			return \fenrir\MysqlStatement::instance($this->dbh, $statement);
		}
	}
387199
protected function prepareIndexes()
    {
        $originalState = SearchVariant::current_state();
        $dirtyIndexes = array();
        $dirty = $this->getSource();
        $indexes = FullTextSearch::get_indexes();
        foreach ($dirty as $base => $statefulids) {
            if (!$statefulids) {
                continue;
            }

            foreach ($statefulids as $statefulid) {
                $state = $statefulid['state'];
                $ids = $statefulid['ids'];

                SearchVariant::activate_state($state);

                // Ensure that indexes for all new / updated objects are included
                $objs = DataObject::get($base)->byIDs(array_keys($ids));
                foreach ($objs as $obj) {
                    foreach ($ids[$obj->ID] as $index) {
                        if (!$indexes[$index]->variantStateExcluded($state)) {
                            $indexes[$index]->add($obj);
                            $dirtyIndexes[$index] = $indexes[$index];
                        }
                    }
                    unset($ids[$obj->ID]);
                }

                // Generate list of records that do not exist and should be removed
                foreach ($ids as $id => $fromindexes) {
                    foreach ($fromindexes as $index) {
                        if (!$indexes[$index]->variantStateExcluded($state)) {
                            $indexes[$index]->delete($base, $id, $state);
                            $dirtyIndexes[$index] = $indexes[$index];
                        }
                    }
                }
            }
        }
        
        SearchVariant::activate_state($originalState);
        return $dirtyIndexes;
    }
1341391
public function prepare() {
        Garp_Cli::lineOut('Preparing Elasticsearch index...');
        $report = $this->_createIndexIfNotExists();
        Garp_Cli::lineOut($report, Garp_Cli::BLUE);
        return true;
    }
609805
public function init()
    {

        // initialize the prepared statements
        $this->categoryDecimalsStmt =
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CATEGORY_DECIMALS));
        $this->categoryDecimalsByPkAndStoreIdStmt =
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CATEGORY_DECIMALS_BY_PK_AND_STORE_ID));
    }
993521
final public function prepare()
    {

        $DB = $this->DBO;
        $QUERY = $this->compile();

        //echo $QUERY;
        //Compile the query;
        $STATEMENT = $DB->prepare($QUERY);

        //Return the Result Object;
        return $STATEMENT;
    }
648666
public function init()
    {

        // initialize the parend class
        parent::init();

        // initialize the prepared statements
        $this->categoryStmt =
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CATEGORY));
    }
1026627
public function init()
    {

        // invoke the parent instance
        parent::init();

        // initialize the prepared statements
        $this->urlRewritesBySkuStmt = $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::URL_REWRITES_BY_SKU));
    }
559237
protected function createIndexes()
    {
        $this->createIndex(
            $this->db->getIndexName(TokensRecord::tableName(), 'providerId', false, true),
            TokensRecord::tableName(),
            'providerId',
            false
        );
    }
763977
public function prepare()
    {
        $return = [];

        $this->getDatabaseConfigs($return);

        if ($this->command->confirm('Do you want to provide an other user to connect to DB?', false))
        {
            $this->getOtherConnectionUser($return);
        }

        $this->generateSqlCommands($return);

        return $return;
    }