-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
185 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,20 +13,36 @@ You can use the DML to perform the following operations: | |
|
||
## Batch insert | ||
|
||
To insert multiple rows into a table, you can use the `Yiisoft\Db\Command\CommandInterface::batchInsert()` method: | ||
To insert multiple rows into a table, you can use the `Yiisoft\Db\Command\CommandInterface::insertBatch()` method: | ||
|
||
```php | ||
use Yiisoft\Db\Connection\ConnectionInterface; | ||
|
||
/** @var ConnectionInterface $db */ | ||
$db->createCommand()->batchInsert( | ||
$db->createCommand()->insertBatch( | ||
'{{%customer}}', | ||
['name', 'email'], | ||
[ | ||
['user1', '[email protected]'], | ||
['user2', '[email protected]'], | ||
['user3', '[email protected]'], | ||
] | ||
], | ||
['name', 'email'], | ||
)->execute(); | ||
``` | ||
|
||
It is possible to insert rows as associative arrays, where the keys are column names. | ||
|
||
```php | ||
use Yiisoft\Db\Connection\ConnectionInterface; | ||
|
||
/** @var ConnectionInterface $db */ | ||
$db->createCommand()->insertBatch( | ||
'{{%customer}}', | ||
[ | ||
['name' => 'user1', 'email' => '[email protected]'], | ||
['name' => 'user2', 'email' => '[email protected]'], | ||
['name' => 'user3', 'email' => '[email protected]'], | ||
], | ||
)->execute(); | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,13 +13,13 @@ Você pode usar o DML para realizar as seguintes operações: | |
|
||
## Inserção em lote | ||
|
||
Para inserir múltiplas linhas em uma tabela, você pode usar o método `Yiisoft\Db\Command\CommandInterface::batchInsert()`: | ||
Para inserir múltiplas linhas em uma tabela, você pode usar o método `Yiisoft\Db\Command\CommandInterface::insertBatch()`: | ||
|
||
```php | ||
use Yiisoft\Db\Connection\ConnectionInterface; | ||
|
||
/** @var ConnectionInterface $db */ | ||
$db->createCommand()->batchInsert( | ||
$db->createCommand()->insertBatch( | ||
'{{%customer}}', | ||
['name', 'email'], | ||
[ | ||
|
@@ -30,6 +30,22 @@ $db->createCommand()->batchInsert( | |
)->execute(); | ||
``` | ||
|
||
It is possible to insert rows as associative arrays, where the keys are column names. | ||
|
||
```php | ||
use Yiisoft\Db\Connection\ConnectionInterface; | ||
|
||
/** @var ConnectionInterface $db */ | ||
$db->createCommand()->insertBatch( | ||
'{{%customer}}', | ||
[ | ||
['name' => 'user1', 'email' => '[email protected]'], | ||
['name' => 'user2', 'email' => '[email protected]'], | ||
['name' => 'user3', 'email' => '[email protected]'], | ||
], | ||
)->execute(); | ||
``` | ||
|
||
## Excluir linhas | ||
|
||
Para excluir linhas de uma tabela, você pode usar o método `Yiisoft\Db\Command\CommandInterface::delete()`: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.