---
title: "Pass values as parameters · Agent Wranglers"
url: https://agentwranglers.se/playbook/data/queries-and-indexes/parameters
updated: 2026-10-20
licence: "All rights reserved"
---

# Pass values as parameters

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Queries and indexes](https://agentwranglers.se/playbook/data/queries-and-indexes)
- Rule: Send every value as a query parameter. Never build SQL by joining strings with input.
- How: Use placeholders such as `$1`, `?` or `%s` in the driver or query builder. Placeholders hold values only. Table names, column names and sort directions cannot be parameters, so map them from a fixed allow-list in code. ORMs are safe until you pass input to their raw SQL functions. The [SQL injection rule](https://agentwranglers.se/playbook/adversarial-testing/injection/sql-injection) shows the attack this stops.
- Check: Search the code for SQL built with string joins or template strings that hold variables. None remain.

Example:

```js
// Bad
db.query(`SELECT id FROM customers WHERE email = '${email}'`);
// Good
db.query('SELECT id FROM customers WHERE email = $1', [email]);
```

```python
# Bad
cursor.execute(f"SELECT id FROM customers WHERE email = '{email}'")
# Good
cursor.execute("SELECT id FROM customers WHERE email = %s", (email,))
```

```php
// Good in PHP with PDO
$statement = $pdo->prepare('SELECT id FROM customers WHERE email = ?');
$statement->execute([$email]);
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers data playbook: https://agentwranglers.se/playbook/data/queries-and-indexes/parameters`.

- Next: [Index the queries you run](https://agentwranglers.se/playbook/data/queries-and-indexes/index-the-queries-you-run)
- [Queries and indexes](https://agentwranglers.se/playbook/data/queries-and-indexes)
