Подготавливает запрос, включающий IN (:array) плейсхолдеры
@param string $sql
@return string $sql
@throws IException
11572
protected function prepareArrayPlaceholders($sql)
    {
        if (!count($this->arrays)) {
            return $sql;
        }
        foreach ($this->arrays as $placeholder => $array) {
            if (strpos($sql, $placeholder) === false) {
                continue;
            }

            $placeholders = [];
            $cnt = count($array);
            for ($i = 0; $i < $cnt; $i++) {
                $placeholders[] = $placeholder . $i;
            }
            $sql = str_replace($placeholder, '(' . implode(', ', $placeholders) . ')', $sql);
        }

        return $sql;
    }
213042
public function query(string $sql)
    {
        $this->lastSql = $sql;
        $this->lastStmt = $this->instance->query($sql);
        if(false === $this->lastStmt)
        {
            throw new DbException('sql prepare error: [' . $this->errorCode() . '] ' . $this->errorInfo() . PHP_EOL . 'sql: ' . $sql . PHP_EOL);
        }
        return BeanFactory::newInstance(Statement::class, $this, $this->lastStmt);
    }
232821
protected function query_one ( $sql )
	{
		$sql = $this->sql_printf(func_get_args()); 
		$row = $this->query_row($sql); 
		$val = array_pop($row);
		return $val;
	}
1343824
public function schema( array $sql )
	{
		$ctx = self::getContext();
		$dbm = $ctx->getDatabaseManager();
		$conn = $dbm->acquire();

		try
		{
			$tables = [];

			foreach( ['fe_users_', 'madmin_', 'mshop_'] as $prefix )
			{
				$result = $conn->create( 'SHOW TABLES like \'' . $prefix . '%\'' )->execute();

				while( ( $row = $result->fetch( \Aimeos\MW\DB\Result\Base::FETCH_NUM ) ) !== false ) {
					$tables[] = $row[0];
				}
			}

			foreach( $tables as $table )
			{
				$result = $conn->create( 'SHOW CREATE TABLE ' . $table )->execute();

				while( ( $row = $result->fetch( \Aimeos\MW\DB\Result\Base::FETCH_NUM ) ) !== false )
				{
					$str = preg_replace( '/,[\n ]*CONSTRAINT.+CASCADE/', '', $row[1] );
					$str = str_replace( '"', '`', $str );

					$sql[] = $str . ";\n";
				}
			}

			$dbm->release( $conn );
		}
		catch( \Exception $e )
		{
			$dbm->release( $conn );
		}


		return ['sqlString' => $sql ];
	}
496044
public function process($sql)
    {
        $bindFormatted=[];
        $bindRaw=[];
        foreach ($this->bindings as $key => $value) {
            if (is_array($value)) {
                $valueSet = implode(', ', $value);

                $values = array_map(
                    function ($value) {
                        return ValueFormatter::formatValue($value);
                    },
                    $value
                );

                $formattedParameter = implode(',', $values);
            } else {
                $valueSet           = $value;
                $formattedParameter = ValueFormatter::formatValue($value);
            }

            if ($formattedParameter !== null) {
                $bindFormatted[$key]=$formattedParameter;
            }

            if ($valueSet !== null) {
                $bindRaw[$key]=$valueSet;
            }
        }

        for ($loop=0;$loop<2;$loop++)
        {
            // dipping in binds
            // example ['A' => '{B}' , 'B'=>':C','C'=>123]
            $sql=$this->compile_binds($sql,$bindRaw,'#{([\w+]+)}#');
        }
        $sql=$this->compile_binds($sql,$bindFormatted,'#:([\w+]+)#');

        return $sql;
    }
737181
protected function _execute($sql)
	{
		return ibase_query(isset($this->_ibase_trans) ? $this->_ibase_trans : $this->conn_id, $sql);
	}
799918
protected function getAliasSql(string $sql): string
    {
        if (!isset($this->alias)) {
            return $sql;
        }

        return sprintf('(%s) AS %s', $sql, $this->quoter->quoteName($this->alias));
    }
1093589
public function exec($sql)
    {
        $return = $this->connection->exec($sql);

        if ($this->useDebug) {
            $this->log($sql);
            $this->setLastExecutedQuery($sql);
            $this->incrementQueryCount();
        }

        return $return;
    }
246467
protected function prepare($sql) {
        $this->checkConnection();

        $sqlKey = md5($sql);
        if ($this->_statementCache->exists($sqlKey))
            return $this->_statementCache->get($sqlKey);

        try {
            // No need to check the connection again
            $statement = $this->getConnection(false)->prepare($sql);
        } catch (\PDOException $pe) {
            throw new \Exception("Error in preparing statement:: query: ".$sql.PHP_EOL."Message: ".$pe->getMessage());
        }

        $this->_statementCache->set($sqlKey, $statement);
        return $statement;
    }
1153388
public function addSql($sql)
    {
        if (is_array($sql)) {
            $this->sql = array_merge($this->sql, $sql);
        } else {
            $this->sql[] = $sql;
        }

        return $this;
    }
211269
private static function getOperation(string $sql): string
    {
        // remove annotion and blank
        $sql = preg_replace('/\/\*[^\/]+\*\//', '', $sql);
        $sql = trim($sql);
        $sql = strtoupper($sql);

        if (strpos($sql, 'INSERT') === 0) {
            return self::RETURN_INSERTID;
        }

        if (strpos($sql, 'UPDATE') === 0 || strpos($sql, 'DELETE') === 0 || strpos($sql, 'REPLACE') === 0) {
            return self::RETURN_ROWS;
        }

        return self::RETURN_FETCH;
    }
1042888
public function quote(string $sql): string
    {
        return preg_replace_callback('#".*\!' . $this->nameRegex . '.*"|\!(' . $this->nameRegex . ')#i', function ($matches) {
            return isset($matches[1]) ? static::quoteName($matches[1]) : $matches[0];
        }, $sql);
    }
1372555
public static function prepareStmt($sql) {
        self::init();
        $db = self::connect();
        return $db->prepare($sql);
    }
958073
protected function replaceTable($sql) {
		$table = $this->getTable();
		$i18nTable = $this->getTranslationTable();
		preg_match_all('/(?<![\.a-zA-Z0-9-_`\(\)])([a-z_][a-zA-Z0-9-_]*)(?![\.`\(\)])/', $sql, $matches);
		foreach($matches[0] as $property) {
			if($this->definition->hasProperty($property))
				$table = $this->definition->property($property)->get('i18n') ? $i18nTable:$table;
			$sql = preg_replace('/(?<![\.a-zA-Z0-9-_`\(\)])('.$property.')(?![\.a-zA-Z0-9-_`\(\)])/', $table.'.$1', $sql);
		}

		return $sql;
	}
764472
protected function prepareExpressionPlaceholders($sql)
    {
        if (!count($this->expressions)) {
            return $sql;
        }
        $sql = str_replace(array_keys($this->expressions), array_values($this->expressions), $sql);

        return $sql;
    }
1246854
public function selectOne($sql)
    {
        $result = $this->execute($sql);
        if ($result->count()) {
            return $result->current();
        }
    }
968002
public function prepare($sql)
    {
        if (! array_key_exists($sql, $this->statements)) {
            $this->statements[$sql] = $this->pdo->prepare($sql);

        }
        return $this->statements[$sql];
    }