Skip to content
Open
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
7 changes: 3 additions & 4 deletions examples/official-site/sqlpage/migrations/08_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ VALUES (
'header',
'0.7.2',
'heading',
'Reads a [header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields) with the given name from the request.
Returns the value of the header as text, or NULL if the header is not present.
'Reads one [HTTP request header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers). Names are case-insensitive: `sqlpage.header(''User-Agent'')` and `sqlpage.header(''user-agent'')` read the same value. An absent header returns SQL `NULL`.

### Example

Expand Down Expand Up @@ -135,7 +134,7 @@ SELECT ''authentication'' AS component,
'0.7.2',
'key',
'Returns the password from the [Basic Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) header of the request.
If the header is not present, this function raises an authorization error that will prompt the user to enter their credentials.
If the header is absent, SQLPage sends an HTTP Basic challenge. Browsers normally respond by prompting for credentials.

### Example

Expand Down Expand Up @@ -262,7 +261,7 @@ Currently running from `/home/user/my_sqlpage_website`

The current working directory is the directory from which the SQLPage server process was started.
By default, this is also the directory from which `.sql` files are loaded and served.
However, this can be changed by setting the `web_root` [configuration option](https://github.com/sqlpage/SQLPage/blob/main/configuration.md).
Setting [`web_root`](https://github.com/sqlpage/SQLPage/blob/main/configuration.md) changes where SQLPage serves files. It does not change the process working directory. Use [`sqlpage.web_root()`](?function=web_root) to get the directory actually being served.
'
);
INSERT INTO sqlpage_functions (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ For more information about SQLPage variables, see the [*SQL in SQLPage* guide](/
- `sqlpage.variables(''post'')` - returns only POST form data
- `sqlpage.variables(''set'')` - returns only user-defined variables created with `SET`

When a SET variable has the same name as a GET or POST variable, the SET variable takes precedence in the combined result.
For example, after `SET page = NULL` on a request to `?page=2`,
`sqlpage.variables(''get'')` still contains `"page":"2"`.
The combined `sqlpage.variables()` contains `"page":null`.

## Example: a form with a variable number of fields

Expand Down Expand Up @@ -114,6 +116,6 @@ VALUES (
'variables',
1,
'method',
'Optional. Filter variables by source: ''get'' (URL parameters), ''post'' (form data), or ''set'' (user-defined variables). When not provided, all variables are returned with SET variables taking precedence over request parameters.',
'Filter by source: `get` for URL parameters, `post` for form fields, or `set` for page variables. With no argument, the result combines all three.',
'TEXT'
);
10 changes: 6 additions & 4 deletions examples/official-site/sqlpage/migrations/47_link.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ where name = $product_name;
> but using `sqlpage.link` is better because it ensures that the URL is properly encoded.
> `sqlpage.link` will work even if the product name contains special characters like `&`, while `CONCAT(...)` would break the URL.

### Parameters
- `file` (TEXT): The name of the SQLPage file to link to.
- `parameters` (JSON): The parameters to pass to the linked file.
- `fragment` (TEXT): An optional fragment (hash) to append to the URL. This is useful for linking to a specific section of a page. For instance if `product.sql` contains `select ''text'' as component, ''product_description'' as id;`, you can link to the product description section with `sqlpage.link(''product.sql'', json_object(''product_name'', name), ''product_description'')`.
To link directly to a section, pass its `id` as the third argument, without the `#`:

```sql
select sqlpage.link(''product.sql'', json_object(''product_name'', name), ''product_description'') as link
from products;
```
'
);

Expand Down
Loading