@throws DatabaseException

@return string
772975
public function create_sid(): string
    {
        $string = '';
        $caracters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-';

        $countCaracters = 62;
        for ($i = 0; $i < 127; ++$i) {
            $string .= $caracters[\rand(0, $countCaracters)];
        }

        $sql = 'SELECT COUNT(id) FROM sessions WHERE id=:id';
        $params = ['id' => $string];
        $count = $this->db->count($sql, $params);
        if ($count !== 0) {
            return $this->create_sid();
        }

        return $string;
    }
420019
public function next(): bool
    {
        try {
            return $this->pdoStatement->nextRowset();
        } catch (PDOException $pdoe) {
            throw new DatabaseException($pdoe->getMessage(), $pdoe);
        }
    }
1336959
private function errorCode()
    {
        if ($this->preparedExec == false){
    		$returnValue = $this->dbConnector->errorCode();
    	}
    	else{
    		$returnValue = $this->lastPreparedExecStatement->errorCode();
    	}
        return (string) $returnValue;
    }
113313
public function getDatabaseName()
    {
        if (isset($this->_data['filter_column']) && is_string($this->_data['filter_column'])) {
            return $this->_data['filter_column'];
        }
        return $this->index();
    }
842128
public function execute()
    {
        try {
            $sql = $this->prepared_sql;

            foreach ($this->param_list as $placeholder => $param) {
                if (strpos($this->prepared_sql, $placeholder) === false) {
                    throw new DatabaseException(__METHOD__ . " missing bound placeholder: $placeholder in sql $this->prepared_sql", MySQL::ERR_CONN, MySQL::SEVERITY_LOG, __FILE__, __LINE__);
                }


                $t = (isset($this->type_list[$placeholder]) ? $this->type_list[$placeholder] : 999999);

                switch ($t) {
                    case self::TYPE_BLOB:
                    case self::TYPE_STRING:
                        $val = "'" . mysql_real_escape_string($param, $this->_db->db) . "'";
                        break;
                    case self::TYPE_INT:
                    case self::TYPE_BOOL:
                        $val = (int)$param;
                        break;
                    case self::TYPE_FLOAT:
                        $val = (float)$param;
                        break;
                    case self::TYPE_NULL:
                        $val = 'NULL';
                        break;
                    default:
                        $val = "'" . (mysql_real_escape_string($param, $this->_db->db)) . "'";
                        break;
                }
                $sql = str_replace($placeholder, $val, $sql);
            }
        } catch (DatabaseException $e) {
            throw $e;
        }

        unset($t, $val, $param);

        /**
         * set the sql for debugging purposes
         */
        $this->sql = $sql;

        /**
         * query the database
         */
        $this->res = $this->_db->query($sql);

        if (!$this->res) return false;

        return $this;
    }
611626
public function toString()
    {
        $sb = 'Criteria:';
        try {

            $params = [];
            $sb .= "\nSQL (may not be complete): ".$this->createSelectSql($params);

            $sb .= "\nParams: ";
            $paramstr = [];
            foreach ($params as $param) {
                $paramstr[] = $param['table'] . '.' . $param['column'] . ' => ' . var_export($param['value'], true);
            }
            $sb .= implode(', ', $paramstr);

        } catch (\Exception $exc) {
            $sb .= '(Error: ' . $exc->getMessage() . ')';
        }

        return $sb;
    }
746075
public function getPrimaryKey()
    {
        $columns = $this->getColumns();

        if (!isset($columns)) {
            throw new DatabaseException('Column schema not found!');
        }

        if (count($columns) > 0) {
            $primaryKey = null;
            foreach ($columns as $key => $value) {
                if ($value['COLUMN_KEY'] == 'PRI' || $value['EXTRA'] == 'auto_increment') {
                    $primaryKey = $value['COLUMN_NAME'];
                    break;
                }
            }
        }

        return $primaryKey;
    }
1034341
protected function sqlInsert(): string
    {
        $inserts = [];
        foreach ($this->datafields as $fieldname => $field) {
            $value = (array_key_exists($fieldname, $this->values)) ? $this->values[$fieldname] : null;
            $escapedFieldName = $this->dbal->sqlFieldEscape($field['name']);
            $inserts[$escapedFieldName] = $this->dbal->sqlQuote($value, $field['commontype'], true);
        }
        if (! count($inserts)) {
            throw new \LogicException('Recordset: Insert does not have any fields to insert');
        }
        return 'INSERT INTO ' . $this->dbal->sqlTableEscape($this->entity)
        . ' (' . implode(', ', array_keys($inserts)) . ')'
        . ' VALUES (' . implode(', ', $inserts) . ')'
        . ';';
    }
172002
protected function getDatabasePath() : string
    {
        $databasePath = $this->getDataDirectory() . DIRECTORY_SEPARATOR . $this->getDatabaseFileName();

        if (!$this->isFileReadable($databasePath)) {
            if (!file_exists($databasePath)) {
                throw new ParserRuntimeException(
                    "Linked database file '$databasePath' not found. Parser data need to be generated.",
                    1458898365
                );
            } else {
                throw new ParserRuntimeException("Linked database file '$databasePath' is not readable.", 1458898366);
            }
        } elseif (!is_file($databasePath)) {
            throw new ParserRuntimeException("Invalid database file name '$databasePath' in link file.", 1458898367);
        }

        return $databasePath;
    }
600305
protected static function getConnection() {
        if (self::$db === null) {
            try {
                self::$db = new PDO(self::$dsn, self::$user, self::$password);
                self::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            } catch (PDOException $e) {
                throw new Exception("DJJob couldn't connect to the database. PDO said [{$e->getMessage()}]");
            }
        }
        return self::$db;
    }
731756
public String getStatement() throws SQLException {
		StringBuilder sb = new StringBuilder();
		appendSql(null, sb, new ArrayList<ArgumentHolder>());
		return sb.toString();
	}
125925
public function getDatabase() : ?string 
    {
        if ( ! $this->hasDatabase()) {
            $this->setDatabase($this->getDefaultDatabase());
        }
        return $this->database;
    }
686854
protected function GetConnectionString()
	{
		$cstring = new DBConnectionString();
		$cstring->Host = RequestUtil::Get('host');
		$cstring->Port = RequestUtil::Get('port');
		$cstring->Username = RequestUtil::Get('username');
		$cstring->Password = RequestUtil::Get('password');
		$cstring->DBName = RequestUtil::Get('schema');
		$cstring->Type = RequestUtil::Get('type','MySQL');
		return $cstring;
	}
831460
private function getResponse()
    {
        $this->lastInsertId = $this->provider->lastInsertId();

        $this->rowCount = $this->provider->rowCount($this->response);

        if (is_null($this->response)) {
            throw new DBException(
                'Error executing the query ' . $this->provider->getError()
            );
        }

        return $this->fetchResponse();
    }
1078572
public function toString()
    {
        if (!$this->_parts['table']) {
            throw new SqlException("Invalid `DROP TABLE` statement, missing `TABLE` clause.");
        }

        return 'DROP TABLE' .
            $this->_buildFlag('IF EXISTS', $this->_parts['ifExists']) .
            $this->_buildChunk($this->dialect()->names($this->_parts['table'])) .
            $this->_buildFlag('CASCADE', $this->_parts['cascade']) .
            $this->_buildFlag('RESTRICT', $this->_parts['restrict']);
    }
693728
public function getAdapter()
    {
        if (is_null($this->adapter) || ! $this->adapter instanceof AdapterInterface) {
            $class = '\\Wslim\\Db\Adapter\\' . $this->options['adapter'] . 'Adapter';
            if (!class_exists($class)) {
                throw new DbException('database adapter is not exists:' . $class);
            }
            
            $this->adapter  =   new $class($this->options);
        }
        
        return $this->adapter;
    }
1253097
public function free(): bool
    {
        try {
            return $this->pdoStatement->closeCursor();
        } catch (PDOException $pdoe) {
            throw new DatabaseException($pdoe->getMessage(), $pdoe);
        }
    }