returns a PDO SQL string that has parameter syntax
@return string
@since v1.0.0
355093
public function getSql()
    {
        $sqlTemplate = "SELECT %s FROM %s %s";
        $fieldsCompiled = implode(',', $this->getFields());
        return trim(sprintf(
            $sqlTemplate,
            $fieldsCompiled,
            $this->getTable(),
            $this->getWhereStatement()
        ));
    }
1263100
public function _getSql()
    {
        $sql = '';
        $params = [];
        try {
            list($sql, $params) = $this->getSqlCompiler(BaseOrm::getDbConnection())->asSql();
        } catch (OrmException $e) {
        }

        $sql = str_replace('?', '%s', $sql);

        return vsprintf($sql, $params);
    }
6296
private function buildDebugSql()
    {
        $bindParams = $this->bindParams;
        foreach ($bindParams as $key => $val) {
            $bindParams[$key] = str_replace('\\\\', '\\', addslashes($val));
        }
        return vsprintf(str_replace('%s', "'%s'", $this->currentSql), $bindParams);
    }
109623
public function get()
    {
        $sql = "SELECT * FROM `$this->_table` ";

        $this->_param_list = array();

        if (!empty($this->_where_list)) {
            $sql .= "WHERE ";
            $first = true;
            foreach ($this->_where_list as $field_name => $field_settings) {
                $type          = isset($field_settings['type']) ? $field_settings['type'] : false;
                $field_value   = $field_settings['value'];
                $field_connect = isset($field_settings['op']) ? $field_settings['op'] : ' AND ';

                switch ($type) {
                    case 'like':
                        $sql .= ($first !== true ? "$field_connect" : "") . "$field_name like '%:$field_name%'";
                        $this->_param_list[] = array(":$field_name", $field_value);
                        break;
                    case 'in':
                        $sql .= ($first !== true ? "$field_connect" : "") . "$field_name IN (:$field_name)";
                        $this->_param_list[] = array(":$field_name", $field_value);
                        break;
                    default:
                        $sql .= ($first !== true ? "$field_connect" : "") . "$field_name = :$field_name";
                        $this->_param_list[] = array(":$field_name", $field_value);
                        break;
                }

                // we can assume that after the first iteration it's false
                $first = false;
            }
        }
        unset($field_connect, $field_name, $field_value, $type, $field_settings);

        if (!empty($this->_group)) {
            if (is_array($this->_group)) {
                $this->_limit = implode(',', $this->_group_by);
            }

            $sql .= ' GROUP BY ' . $this->_group_by;
        }

        if (!empty($this->_limit)) {
            if (is_array($this->_limit)) {
                $this->_limit = implode(',', $this->_limit);
            }

            $sql .= ' LIMIT ' . $this->_limit;
        }

        $this->last_sql = $sql;

        $this->__init_database();

        $stmt = $this->db->prepare($sql);
        // set the prepared statement
        for ($i = 0, $c = count($this->_param_list); $i < $c; $i++) {
            $stmt->bindParam($this->_param_list[$i][0], $this->_param_list[$i][1]);
        }


        if (!$stmt->execute()) return;

        $this->result = $stmt->fetchAll(MySQL::FETCH_OBJ);
    }
1197272
protected function replaceParamInSql()/*# : string */
    {
        $count = 0;
        $params = $this->params;
        return preg_replace_callback(
            '/\?|\:\w+/',
            function ($m) use ($count, $params) {
                if ('?' === $m[0]) {
                    $res = $params[$count++];
                } else {
                    $res = isset($params[$m[0]]) ? $params[$m[0]] :
                        $params[substr($m[0], 1)];
                }
                return $this->getDriver()->quote($res);
            },
            $this->sql
        );
    }
865326
public function toString()
	{
		// Build the actual query
		if (is_object($this->statement))
		{
			$query = $this->interpolate($this->statement->queryString, $this->bindings);
		}
		else
		{
			$query = $this->statement;
		}

		return $query;
	}
739312
public function debugDumpParams()
    {
        $str  = "SQL: [".strlen($this->_statement)."] ".$this->_statement."\n";
        $str .= "Params: ".sizeof($this->_binds)."\n";
        foreach ($this->_binds as $key => $value) {
            $str .= "Key: Name: [".strlen($key)."] $key\n";
            $str .= "name=[".strlen($key)."] \"$key\"\n";
            $str .= "is_param=1\n";
        }
        echo substr($str, 0, strlen($str)-1);
    }
166119
public function getPdo() : PDO
    {
        if(empty($this->pdo)) {
            $this->pdo = new PDO("sqlite:".$this->getDir().$this->getFileNames()[0]);
        }
        return $this->pdo;
    }
827270
public function sql(): string
    {
        if (empty($this->parts)) {
            return '1';
        }
        return (string) \array_reduce(
            $this->parts,
            function (string $sql, array $part): string {
                /** @var string|self $condition */
                $condition = $part['condition'];

                if ($this->isGroup($condition)) {
                    // (...)
                    if (\is_string($condition)) {
                        $statement = '(' . $condition . ')';
                    } else {
                        $statement = '(' . $condition->sql() . ')';
                    }
                } else {
                    // foo = ?
                    $statement = $condition;
                }
                /** @var string $statement */
                $statement = (string) $statement;
                $part['type'] = (string) $part['type'];

                if ($sql) {
                    switch ($part['type']) {
                        case 'AND':
                        case 'OR':
                            $statement = $part['type'] . ' ' . $statement;
                            break;
                        default:
                            throw new RuntimeException(
                                \sprintf('Invalid joiner %s', $part['type'])
                            );
                    }
                }

                return \trim($sql . ' ' . $statement);
            },
            ''
        );
    }
1089254
function ToString()
    {
        $resultArr = array((string)$this->tables[0]);
        foreach ($this->tables as $key=>$table)
        {
            if ($key == 0)
                 continue;
                
            $part = (string)$this->joins[$key - 1]; 
            $part .= ' ' . (string)$table;
            $part .= ' ON ' . (string)$this->conditions[$key - 1];

            $resultArr[] = $part;
        }
        return join(' ', $resultArr);
    }
1138163
private function getPdo()
    {
        static $pdo = null;

        if (is_null($pdo)) {
            $builder = new InstanceBuilder();
            $pdo = $builder->build('PDO', $this->args);
        }

        return $pdo;
    }
1252017
public function getSqlWithParams($quotationChar = '<>')
    {
        if (($l = strlen($quotationChar)) > 1) {
            $quoteLeft  = substr($quotationChar, 0, $l / 2);
            $quoteRight = substr($quotationChar, $l / 2);
        } else {
            $quoteLeft = $quoteRight = $quotationChar;
        }

        $sql = $this->sql;
        foreach ($this->parameters as $k => $v) {
            $v = "$quoteLeft$v$quoteRight";
            if (!is_numeric($k)) {
                $sql = str_replace($k, $v, $sql);
            } else {
                $p   = strpos($sql, '?');
                $sql = substr($sql, 0, $p) . $v . substr($sql, $p + 1);
            }
        }
        return $sql;
    }
577428
protected function getPDO()
    {
        if (null === $this->pdo) {
            $this->pdo = new \PDO($this->dsn, $this->user, $this->password, $this->options);
        }
        return $this->pdo;
    }
221194
public function get_PDO_param($var) {
        switch($var) {
            case is_int($var):
                $param_datatype = \PDO::PARAM_INT;
                break;
            case is_string($var):
                $param_datatype = \PDO::PARAM_STR;
                break;
            default:
                $param_datatype = \PDO::PARAM_INT;
        }

        return $param_datatype;
    }
170293
public function getConnectionString()
    {
        $this->parseDsn();
        $connect_parameters = [
            sprintf(
                "user=%s dbname=%s",
                $this->configuration['user'],
                $this->configuration['database']
            )
        ];

        if ($this->configuration['host'] !== '') {
            $connect_parameters[] = sprintf('host=%s', $this->configuration['host']);
        }

        if ($this->configuration['port'] !== '') {
            $connect_parameters[] = sprintf('port=%s', $this->configuration['port']);
        }

        if ($this->configuration['pass'] !== '') {
            $connect_parameters[] = sprintf('password=%s', addslashes($this->configuration['pass']));
        }

        return join(' ', $connect_parameters);
    }
984112
protected function getPdoStatement()
    {
        $statement = $this->connection->prepare($this->getSql());
        if ($this->dataRowClass !== null) {
            $statement->setFetchMode(PDO::FETCH_CLASS, $this->dataRowClass);
        } else {
            $statement->setFetchMode(PDO::FETCH_OBJ);
        }
        return $statement;
    }
676435
public function toSql()
    {
        if ($this->isEmpty()) {
            return '';
        }

        $params = $this->getParams();

        $sql = array('SET');
        $set = array();

        foreach ($params as $column => $value) {
            $set[] = implode(' = ', array(
                $column, $this->getBuilder()->getHelper()->toDbValue($value)
            ));
        }

        $sql[] = implode(', ', $set);

        return implode(' ', $sql);
    }