mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 22:21:48 +00:00
* refactor: Add h1 headers to all pages missing it * refactor: missed example h3 * change hooks example heading to bold text --------- Co-authored-by: Luke <[email protected]>
21 lines
754 B
Plaintext
21 lines
754 B
Plaintext
# Placeholders
|
|
|
|
Placeholders allow for query parameters to be safely executed, preventing [common SQL injection methods](https://bobby-tables.com/).
|
|
|
|
Parameters can be passed an an array or map (referred to as named named parameters).
|
|
|
|
```lua
|
|
local identifier = 'license:abc123'
|
|
local group = 'admin'
|
|
|
|
MySQL.scalar('SELECT `username` FROM `users` WHERE `identifier` = ? AND `group` = ?', { identifier, group })
|
|
|
|
-- Named placeholders (deprecated)
|
|
MySQL.scalar('SELECT `username` FROM `users` WHERE `identifier` = @identifier AND `group` = @group', {
|
|
group = group
|
|
identifier = identifier
|
|
})
|
|
```
|
|
|
|
These are distinct from prepared statements which are handled by the MySQL server; you can use `MySQL.prepare` for more optimised and secure queries.
|