mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-01 22:21:51 +00:00
Update index.md
This commit is contained in:
1 parent
5479a9168b
commit
9c4eb9814d
1 file changed
+4
-78
@@ -13,85 +13,11 @@ TODO
|
||||
Every executed query is being prepared and stored into cache for faster performance using prepared statements. These statements are also being sanitized from vulnerable SQL injection and accepts two types of parameters:
|
||||
|
||||
```lua
|
||||
...'SELECT * FROM `users` WHERE `identifier` = ? AND `group` = ?', { playerIdentifier, playerGroup } ...
|
||||
...'SELECT * FROM `users` WHERE `identifier` = ? AND `group` = ?',
|
||||
{ playerIdentifier, playerGroup } ...
|
||||
```
|
||||
|
||||
```lua
|
||||
...'SELECT * FROM `users` WHERE `identifier` = :id AND `group` = :group', { id = playerIdentifier, group = playerGroup }
|
||||
...'SELECT * FROM `users` WHERE `identifier` = :id AND `group` = :group',
|
||||
{ id = playerIdentifier, group = playerGroup }
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Execute
|
||||
|
||||
Will execute query and returns count of affected rows.
|
||||
|
||||
```lua
|
||||
exports.oxmysql:execute(query, {}, function(affectedRows)
|
||||
|
||||
end)
|
||||
print('I will be printed before query result')
|
||||
|
||||
--
|
||||
|
||||
local affectedRows = exports.oxmysql:executeSync(query, {})
|
||||
print('I will be printed after query result')
|
||||
```
|
||||
|
||||
### Insert
|
||||
|
||||
Async wrapper
|
||||
|
||||
```lua
|
||||
exports.oxmysql:insert(query, {}, function(insertId)
|
||||
|
||||
end)
|
||||
print('I will be printed before query result')
|
||||
|
||||
--
|
||||
|
||||
local insertId = exports.oxmysql:insertSync(query, {})
|
||||
print('I will be printed after query result')
|
||||
```
|
||||
### Fetch
|
||||
|
||||
```lua
|
||||
exports.oxmysql:fetch(query, {}, function(result)
|
||||
|
||||
end)
|
||||
print('I will be printed before query result')
|
||||
|
||||
--
|
||||
|
||||
local result = exports.oxmysql:executeSync(query, {})
|
||||
print('I will be printed after query result')
|
||||
```
|
||||
|
||||
### Single
|
||||
|
||||
```lua
|
||||
exports.oxmysql:execute(query, {}, function(rowData)
|
||||
|
||||
end)
|
||||
print('I will be printed before query result')
|
||||
|
||||
--
|
||||
|
||||
local rowData = exports.oxmysql:executeSync(query, {})
|
||||
print('I will be printed after query result')
|
||||
```
|
||||
|
||||
### Scalar
|
||||
|
||||
```lua
|
||||
exports.oxmysql:execute(query, {}, function(affectedRows)
|
||||
|
||||
end)
|
||||
print('I will be printed before query result')
|
||||
|
||||
--
|
||||
|
||||
local affectedRows = exports.oxmysql:executeSync(query, {})
|
||||
print('I will be printed after query result')
|
||||
```
|
||||
|
||||
Reference in new issue
Block a user