sql = $sql; $this->flags = $flags; $this->queryVerb = $queryVerb; $this->writeTable = $writeTable; $this->cleanedSql = substr( $cleanedSql, 0, 255 ); } public function isWriteQuery(): bool { // Check if a SQL wrapper method already flagged the query as a non-write if ( $this->fieldHasBit( $this->flags, SQLPlatform::QUERY_CHANGE_NONE ) || $this->fieldHasBit( $this->flags, SQLPlatform::QUERY_CHANGE_TRX ) || $this->fieldHasBit( $this->flags, SQLPlatform::QUERY_CHANGE_LOCKS ) ) { return false; } // Check if a SQL wrapper method already flagged the query as a write if ( $this->fieldHasBit( $this->flags, SQLPlatform::QUERY_CHANGE_ROWS ) || $this->fieldHasBit( $this->flags, SQLPlatform::QUERY_CHANGE_SCHEMA ) || $this->fieldHasBit( $this->flags, SQLPlatform::QUERY_PSEUDO_PERMANENT ) ) { return true; } throw new DBLanguageError( __METHOD__ . ' called with incorrect flags parameter' ); } public function getVerb(): string { return $this->queryVerb; } private function fieldHasBit( int $flags, int $bit ): bool { return ( ( $flags & $bit ) === $bit ); } public function getSQL(): string { return $this->sql; } public function getFlags(): int { // The whole concept of flags is terrible. This should be deprecated. return $this->flags; } /** * Get the table which is being written to, or null for a read query or if * the destination is unknown. */ public function getWriteTable(): ?string { return $this->writeTable; } /** * Get the cleaned/sanitized SQL statement text for logging. * Might return an empty string, which means sanitization is the caller's responsibility. */ public function getCleanedSql(): string { return $this->cleanedSql; } }