Files
Database/docs/ru/api-query.md
2026-01-15 22:38:46 +03:00

34 lines
721 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Query API (RU)
Raw SQL через `api.query()` с биндингом параметров.
## Execute
```java
int rows = api.query().execute(
"UPDATE players SET level = level + 1 WHERE id = ?",
java.util.Collections.singletonList(1)
);
```
## Query
```java
List<String> names = api.query().query(
"SELECT name FROM players WHERE level >= ?",
java.util.Collections.singletonList(10),
rs -> rs.getString("name")
);
```
## Транзакции
```java
try (Transaction tx = api.beginTransaction()) {
tx.execute("UPDATE players SET level = level + 1 WHERE id = ?", java.util.Collections.singletonList(1));
tx.commit();
} catch (Exception ex) {
// rollback при ошибке
}
```