# Query

Extracts data from a database table using a custom SQL query.

```php
$etl->extract('query', 'select * from users', $options);
```

## Options

### Connection

Name of the database connection to use.

| Type   | Default value |
| ------ | ------------- |
| string | default       |

```php
$options = ['connection' => 'app'];
```

### Bindings

Values to bind to the query statement.

| Type  | Default value |
| ----- | ------------- |
| array | `[]`          |

Using prepared statement with named placeholders `select * from users where status = :status`:

```php
$options = ['bindings' => ['status' => 'active']];
```

Using prepared statement with question mark placeholders `select * from users where status = ?`:

```php
$options = ['bindings' => ['active']];
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://php-etl.gitbook.io/docs/extractors/query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
