{@inheritdoc}

@throws SQLAnywhereException
544827
public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null)
    {
        switch ($type) {
            case ParameterType::INTEGER:
            case ParameterType::BOOLEAN:
                $type = 'i';
                break;

            case ParameterType::LARGE_OBJECT:
                $type = 'b';
                break;

            case ParameterType::NULL:
            case ParameterType::STRING:
            case ParameterType::BINARY:
                $type = 's';
                break;

            default:
                throw new SQLAnywhereException('Unknown type: ' . $type);
        }

        $this->boundValues[$column] =& $variable;

        if (! sasql_stmt_bind_param_ex($this->stmt, $column - 1, $variable, $type, $variable === null)) {
            throw SQLAnywhereException::fromSQLAnywhereError($this->conn, $this->stmt);
        }

        return true;
    }
395925
public QueryBuilder<T, ID> join(String localColumnName, String joinedColumnName,
			QueryBuilder<?, ?> joinedQueryBuilder, JoinType type, JoinWhereOperation operation) throws SQLException {
		addJoinInfo(type, localColumnName, joinedColumnName, joinedQueryBuilder, operation);
		return this;
	}
1058150
public function bindWhere()
    {
        if (count($this->wheresBindValue) > 0) {
            foreach ($this->wheresBindValue as $value) {
                $bindDataType = $this->bindDataType($value[2]);
                $this->sqlQuery->bindValue($this->positioningMarker, $value[2], $bindDataType);

                $this->positioningMarker++;
            }
        }

        return $this;
    }
1045690
private void setFkWhere(Where<MetadataReference, Void> where, long fileId,
			Long parentId) throws SQLException {

		where.eq(MetadataReference.COLUMN_FILE_ID, fileId);
		if (parentId == null) {
			where.and().isNull(MetadataReference.COLUMN_PARENT_ID);
		} else {
			where.and().eq(MetadataReference.COLUMN_PARENT_ID, parentId);
		}

	}
1173087
private void setWhere(Where where) throws SqlParseException {
        if (where != null) {
            QueryBuilder whereQuery = QueryMaker.explan(where,this.select.isQuery);
            request.setQuery(whereQuery);
        }
    }
476441
public function processSql(SqlInterface $sql)
    {
        /** @var CreateTable $sql */
        $this->_sql = $sql;
        $tableName = $this->_sql->getTable();
        $template = "CREATE TABLE %s (%s)";
        $parts = ArrayMethods::clean(
            [$this->_parseColumns(), $this->_parseConstraints()]
        );
        return sprintf(
            $template,
            $tableName,
            implode(', ', $parts)
        );
    }
601471
public function processSql(SqlInterface $sql)
    {
        $this->_sql = $sql;
        $template = "INSERT INTO %s (%s) VALUES (%s)";
        return sprintf(
            $template,
            $this->_sql->getTable(),
            $this->_sql->getFieldList(),
            $this->_sql->getPlaceholderList()
        );
    }
400060
public function processSql(SqlInterface $sql)
    {
        $this->_sql = $sql;
        $template = "UPDATE %s SET %s WHERE %s";
        return sprintf(
            $template,
            $this->_sql->getTable(),
            $this->_getFieldsAndPlaceholders(),
            $this->_sql->getWhereStatement()
        );
    }
1028122
public Entity get(Entity where) throws SQLException {
		return db.find(null, fixEntity(where), new EntityHandler());
	}
786920
public function execute($bindWhereParam = [])
    {

        // clean query from white space
        $sql = trim($this->STH->queryString);
        // get operation type
        $operation = explode(' ', $sql);
        // make first word in uppercase
        $operation[0] = strtoupper($operation[0]);

        if (!empty($bindWhereParam)) {
            $this->_bindPdoParam($bindWhereParam);
        }

        // use try catch block to get pdo error
        try {
            // run pdo statement with bind param
            if ($this->STH->execute()) {
                // check operation type
                switch ($operation[0]) {
                    case 'SELECT':
                        // get affected rows by select statement
                        $this->affectedRows = $this->STH->rowCount();
                        // get pdo result array
                        $this->results = $this->STH->fetchAll();
                        // return PDO instance
                        return $this;
                        break;
                    case 'INSERT':
                        // return last insert id
                        $this->lastId = $this->lastInsertId();
                        // return PDO instance
                        return $this;
                        break;
                    case 'UPDATE':
                        // get affected rows
                        $this->affectedRows = $this->STH->rowCount();
                        // return PDO instance
                        return $this;
                        break;
                    case 'DELETE':
                        // get affected rows
                        $this->affectedRows = $this->STH->rowCount();
                        // return PDO instance
                        return $this;
                        break;
                }
                // close pdo cursor
                $this->STH->closeCursor();
            } else {
                self::error($this->STH->errorInfo());
            }
        } catch (\PDOException $e) {
            // get pdo error and pass on error method
            self::error($e->getMessage() . ': ' . __LINE__);
        }
    }
1184546
public function pdoQuery($sql = '', $bindWhereParam = [])
    {
        // Check empty query
        if (empty($sql)) {
            self::error('Query is empty..');
        }

        // clean query from white space
        $sql = trim($sql);
        // get operation type
        $operation = explode(' ', $sql);
        // make first word in uppercase
        $operation[0] = strtoupper($operation[0]);

        // set class property with pass value
        $this->sql = $sql;
        // set class statement handler
        $this->STH = $this->prepare($this->sql);

        // check valid sql operation statement
        if (!in_array($operation[0], $this->validOperation)) {
            self::error('invalid operation called in query. use only ' . implode(', ',
                    $this->validOperation) . ' You can have NO SPACE be between ' . implode(', ',
                    $this->validOperation) . ' AND parms');
        }

        // sql query pass with no bind param
        if (count($bindWhereParam) <= 0) {

            // try catch block start
            try {
                // execute pdo statement
                if ($this->STH->execute()) {
                    // get affected rows and set it to class property
                    $this->affectedRows = $this->STH->rowCount();
                    // set pdo result array with class property
                    $this->results = $this->STH->fetchAll();
                    // close pdo cursor
                    $this->STH->closeCursor();
                    // return pdo result
                    return $this;
                } else {
                    self::error($this->STH->errorInfo()); // if not run pdo statement sed error
                }
            } catch (\PDOException $e) {
                self::error($e->getMessage() . ': ' . __LINE__);
            } // end try catch block
        } elseif (count($bindWhereParam) > 0) {  // if query pass with bind param

            $this->data = $bindWhereParam;
            // start binding fields
            // bind pdo param
            $this->_bindPdoParam($bindWhereParam);
            // use try catch block to get pdo error
            try {
                // run pdo statement with bind param
                if ($this->STH->execute()) {
                    // check operation type
                    switch ($operation[0]) {
                        case 'SELECT':
                            // get affected rows by select statement
                            $this->affectedRows = $this->STH->rowCount();
                            // get pdo result array
                            $this->results = $this->STH->fetchAll();
                            // return PDO instance
                            return $this;
                            break;
                        case 'INSERT':
                            // return last insert id
                            $this->lastId = $this->lastInsertId();
                            // return PDO instance
                            return $this;
                            break;
                        case 'UPDATE':
                            // get affected rows
                            $this->affectedRows = $this->STH->rowCount();
                            // return PDO instance
                            return $this;
                            break;
                        case 'DELETE':
                            // get affected rows
                            $this->affectedRows = $this->STH->rowCount();
                            // return PDO instance
                            return $this;
                            break;
                    }
                    // close pdo cursor
                    $this->STH->closeCursor();
                } else {
                    self::error($this->STH->errorInfo());
                }
            } catch (\PDOException $e) {
                self::error($e->getMessage() . ': ' . __LINE__);
            } // end try catch block to get pdo error
        } else {
            self::error('Error Query');
        }
    }
48809
public function processSql(SqlInterface $sql)
    {
        $this->_sql = $sql;
        $this->_getSelectFieldsAndTable()
            ->_setJoins()
            ->_getWhereConditions()
            ->_setOrder()
            ->_setLimit();
        return $this->_statement;
    }
726577
@Override
	public int update(Extensions extensions) throws SQLException {

		UpdateBuilder<Extensions, Void> ub = updateBuilder();
		ub.updateColumnValue(Extensions.COLUMN_DEFINITION,
				extensions.getDefinition());
		ub.updateColumnValue(Extensions.COLUMN_SCOPE, extensions.getScope()
				.getValue());

		setUniqueWhere(ub.where(), extensions.getExtensionName(), true,
				extensions.getTableName(), true, extensions.getColumnName());

		PreparedUpdate<Extensions> update = ub.prepare();
		int updated = update(update);

		return updated;
	}
514518
public function setToSql(): array
    {
        if (!$this->set) {
            throw new SqlException('Undefined UPDATE SET columns.');
        }

        $sql = $params = [];

        foreach ($this->set as $item) {
            $sqlPart = $item['sql'];

            $item['params'] && $params = array_merge($params, $item['params']);

            $sql[] = $sqlPart;
        }

        $sql = 'SET ' . implode(', ', $sql);

        return [$sql, $params];
    }
1313908
private void setUniqueWhere(Where<DataColumnConstraints, Void> where,
			String constraintName, DataColumnConstraintType constraintType,
			String value) throws SQLException {

		where.eq(DataColumnConstraints.COLUMN_CONSTRAINT_NAME, constraintName)
				.and()
				.eq(DataColumnConstraints.COLUMN_CONSTRAINT_TYPE,
						constraintType.getValue());
		if (value == null) {
			where.and().isNull(DataColumnConstraints.COLUMN_VALUE);
		} else {
			where.and().eq(DataColumnConstraints.COLUMN_VALUE, value);
		}

	}
225284
public function select($tableName, $where = null, $afterWhere = '')
    {
        return $this->pdo->select($tableName, $where, $afterWhere);
    }
931568
public function execute()
	{
		$this->connect();

		if (!is_object($this->connection))
		{
			$this->log(
				Log\LogLevel::ERROR,
				'Database query failed (error #{code}): {message}',
				array('code' => $this->errorNum, 'message' => $this->errorMsg)
			);
			throw new \RuntimeException($this->errorMsg, $this->errorNum);
		}

		// Take a local copy so that we don't modify the original query and cause issues later
		$sql = $this->replacePrefix((string) $this->sql);

		if ($this->limit > 0 || $this->offset > 0)
		{
			// @TODO
			$sql .= ' LIMIT ' . $this->offset . ', ' . $this->limit;
		}

		// Increment the query counter.
		$this->count++;

		// If debugging is enabled then let's log the query.
		if ($this->debug)
		{
			// Add the query to the object queue.
			$this->log(
				Log\LogLevel::DEBUG,
				'{sql}',
				array('sql' => $sql, 'category' => 'databasequery', 'trace' => debug_backtrace())
			);
		}

		// Reset the error values.
		$this->errorNum = 0;
		$this->errorMsg = '';

		// Execute the query.
		$this->executed = false;

		if ($this->prepared instanceof \PDOStatement)
		{
			// Bind the variables:
			if ($this->sql instanceof PreparableInterface)
			{
				$bounded =& $this->sql->getBounded();

				foreach ($bounded as $key => $obj)
				{
					$this->prepared->bindParam($key, $obj->value, $obj->dataType, $obj->length, $obj->driverOptions);
				}
			}

			$this->executed = $this->prepared->execute();
		}

		// If an error occurred handle it.
		if (!$this->executed)
		{
			// Get the error number and message before we execute any more queries.
			$errorNum = (int) $this->connection->errorCode();
			$errorMsg = (string) 'SQL: ' . implode(", ", $this->connection->errorInfo());

			// Check if the server was disconnected.
			if (!$this->connected())
			{
				try
				{
					// Attempt to reconnect.
					$this->connection = null;
					$this->connect();
				}
				catch (\RuntimeException $e)
				// If connect fails, ignore that exception and throw the normal exception.
				{
					// Get the error number and message.
					$this->errorNum = (int) $this->connection->errorCode();
					$this->errorMsg = (string) 'SQL: ' . implode(", ", $this->connection->errorInfo());

					// Throw the normal query exception.
					$this->log(
						Log\LogLevel::ERROR,
						'Database query failed (error #{code}): {message}',
						array('code' => $this->errorNum, 'message' => $this->errorMsg)
					);
					throw new \RuntimeException($this->errorMsg, $this->errorNum);
				}

				// Since we were able to reconnect, run the query again.
				return $this->execute();
			}
			else
			// The server was not disconnected.
			{
				// Get the error number and message from before we tried to reconnect.
				$this->errorNum = $errorNum;
				$this->errorMsg = $errorMsg;

				// Throw the normal query exception.
				$this->log(
					Log\LogLevel::ERROR,
					'Database query failed (error #{code}): {message}',
					array('code' => $this->errorNum, 'message' => $this->errorMsg)
				);
				throw new \RuntimeException($this->errorMsg, $this->errorNum);
			}
		}

		return $this->prepared;
	}