Skip to content

Commit

Permalink
nette/database v3.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 10, 2022
1 parent 3736d38 commit e3dd1db
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions database/cs/configuration.texy
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ database:
password: ...
```

Vytvoří službu `Nette\Database\Connection` a `Nette\Database\Explorer` pro vrstvu [Database Explorer|explorer]. Databáze se obvykle předává autowiringem, není-li to možné, použijte názvy služeb `@database.default.connection` resp. `@database.default.context`.
Vytvoří službu `Nette\Database\Connection` a `Nette\Database\Explorer` pro vrstvu [Database Explorer|explorer]. Databáze se obvykle předává autowiringem, není-li to možné, použijte názvy služeb `@database.default.connection` resp. `@database.default.explorer`.

Další nastavení:

Expand Down Expand Up @@ -79,7 +79,7 @@ database:
dsn: 'sqlite::memory:'
```

Každé takto definované spojení vytváří služby zahrnující v názvu i název sekce, tj. `@database.main.connection` & `@database.main.context` a dále `@database.another.connection` & `@database.another.context`.
Každé takto definované spojení vytváří služby zahrnující v názvu i název sekce, tj. `@database.main.connection` & `@database.main.explorer` a dále `@database.another.connection` & `@database.another.explorer`.

Autowiring je zapnutý jen u služeb z první sekce. Lze to změnit pomocí `autowired: false` nebo `autowired: true`. Neautowirované služby předáváme explicitně:

Expand Down
3 changes: 2 additions & 1 deletion database/cs/core.texy
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,14 @@ $database->query('INSERT INTO users', [
// INSERT INTO users (`name`, `year`) VALUES ('Jim', 1978), ('Jack', 1987)
```

Jako parametry můžeme předávat i soubory nebo objekty DateTime:
Jako parametry můžeme předávat i soubory, objekty DateTime nebo [výčtové typy |https://www.php.net/enumerations]:

```php
$database->query('INSERT INTO users', [
'name' => $name,
'created' => new DateTime, // nebo $database::literal('NOW()')
'avatar' => fopen('image.gif', 'r'), // vloží soubor
'status' => State::New, // enum State
]);
```

Expand Down
4 changes: 2 additions & 2 deletions database/en/configuration.texy
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ database:
password: ...
```

It creates services of type `Nette\Database\Connection` and also `Nette\Database\Explorer` for the [Database Explorer|explorer] layer. The database connection is usually passed by autowiring, if this is not possible, use the service names `@database.default.connection` resp. `@database.default.context`.
It creates services of type `Nette\Database\Connection` and also `Nette\Database\Explorer` for the [Database Explorer|explorer] layer. The database connection is usually passed by autowiring, if this is not possible, use the service names `@database.default.connection` resp. `@database.default.explorer`.

Other settings:

Expand Down Expand Up @@ -75,7 +75,7 @@ database:
dsn: 'sqlite::memory:'
```

Each defined connection creates services that includes section name in their name, ie `@database.main.connection` & `@database.main.context` and further `@database.another.connection` & `@database.another.context`.
Each defined connection creates services that includes section name in their name, ie `@database.main.connection` & `@database.main.explorer` and further `@database.another.connection` & `@database.another.explorer`.

Autowiring is enabled only for services from the first section. This can be changed with `autowired: false` or `autowired: true`. Non-autowired services are passed by name:

Expand Down
3 changes: 2 additions & 1 deletion database/en/core.texy
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,14 @@ $database->query('INSERT INTO users', [
// INSERT INTO users (`name`, `year`) VALUES ('Jim', 1978), ('Jack', 1987)
```

We can also pass files or DateTime objects:
We can also pass files, DateTime objects or [enumerations |https://www.php.net/enumerations]:

```php
$database->query('INSERT INTO users', [
'name' => $name,
'created' => new DateTime, // or $database::literal('NOW()')
'avatar' => fopen('image.gif', 'r'), // inserts file contents
'status' => State::New, // enum State
]);
```

Expand Down

0 comments on commit e3dd1db

Please sign in to comment.