Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Docs

on:
push:
branches:
- master
paths:
- 'docs/**'
- 'mkdocs.yml'
workflow_dispatch:

permissions:
contents: write

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Instalar MkDocs
run: pip install mkdocs-material

- name: Deploy GitHub Pages
run: mkdocs gh-deploy --force
99 changes: 99 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Documentação — mysql_samp

Plugin MySQL para SA:MP e open.mp escrito em Rust. Zero dependências externas, queries non-blocking, cache e ORM integrados.

---

## Por onde começar?

<div class="grid cards" markdown>

- :material-download: **Novo por aqui**

---

Instale o plugin e configure sua primeira conexão.

[Instalação](instalacao.md) · [Conexão](conexao.md)

- :material-swap-horizontal: **Migrando do R41-4**

---

Veja o que mudou e adapte seu código existente.

[Guia de migração](migracao.md) · [O que mudou](mudancas.md)

- :material-book-open-variant: **Referência**

---

Tabela completa de natives, forwards e enums.

[API completa](api.md)

- :material-speedometer: **Benchmark**

---

Resultados de desempenho em cenários reais.

[Ver benchmark](benchmark.md)

</div>

---

## Exemplo mínimo

Conexão, query assíncrona e leitura do resultado no callback:

```pawn
#include <mysql_samp>

new MySQL:g_mysql;

public OnGameModeInit()
{
g_mysql = mysql_connect("127.0.0.1", "root", "senha", "banco");

// Query FIFO (non-blocking) — executa em thread separada
mysql_query(g_mysql, "SELECT id, nome FROM jogadores LIMIT 5", "OnJogadoresCarregados", "");
return 1;
}

forward OnJogadoresCarregados(errorid, error[]);
public OnJogadoresCarregados(errorid, error[])
{
if (errorid != 0) {
printf("[MySQL] Erro %d: %s", errorid, error);
return;
}

while (cache_next_row()) {
new id, nome[MAX_PLAYER_NAME];
cache_get_value_name_int("id", id);
cache_get_value_name("nome", nome);
printf("Jogador #%d: %s", id, nome);
}
}

public OnGameModeExit()
{
mysql_close(g_mysql);
return 1;
}
```

---

## Tópicos

| Tópico | Descrição |
|---|---|
| [Queries](queries.md) | `mysql_query`, `mysql_pquery`, `mysql_format`, escape de strings |
| [Cache](cache.md) | Leitura de resultados, navegação entre linhas, cache salvo |
| [ORM](orm.md) | Mapeamento de variáveis Pawn para colunas, CRUD automático |
| [Options](options.md) | Configuração de porta, charset, timeout e outros |
| [Segurança](seguranca.md) | Proteção contra SQL injection, limites e boas práticas |
| [Erros](erros.md) | `mysql_errno`, `OnQueryError`, códigos de erro do MySQL |
67 changes: 67 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
site_name: mysql_samp
site_description: Plugin MySQL para SA:MP escrito em Rust
site_url: https://nullsablex.github.io/mysql_samp
repo_url: https://github.com/NullSablex/mysql_samp
repo_name: NullSablex/mysql_samp
edit_uri: edit/master/docs/

theme:
name: material
language: pt
palette:
- scheme: default
primary: deep orange
accent: orange
toggle:
icon: material/brightness-7
name: Modo escuro
- scheme: slate
primary: deep orange
accent: orange
toggle:
icon: material/brightness-4
name: Modo claro
features:
- navigation.tabs
- navigation.sections
- navigation.top
- search.highlight
- search.suggest
- content.code.copy
- content.action.edit

plugins:
- search:
lang: pt

markdown_extensions:
- admonition
- pymdownx.details
- pymdownx.superfences
- pymdownx.highlight:
anchor_linenums: true
- pymdownx.inlinehilite
- pymdownx.tabbed:
alternate_style: true
- tables
- toc:
permalink: true

nav:
- Início: index.md
- Guia:
- Instalação: instalacao.md
- Conexão: conexao.md
- Queries: queries.md
- Cache: cache.md
- ORM: orm.md
- Options: options.md
- Segurança: seguranca.md
- Erros: erros.md
- Migração:
- Guia de Migração: migracao.md
- O que Mudou: mudancas.md
- Exemplos: exemplos-migracao.md
- Referência:
- API Completa: api.md
- Benchmark: benchmark.md