Skip to content

Commit

Permalink
use restore
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarpunk committed Apr 15, 2021
1 parent 464b365 commit 7744704
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Call.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ class Call {
private string $connection;
private static string $connection_default;

private string $use = '';
private string $use_before = '';
private string $use_after = '';

public function __construct(string $procedure) {
$this->connection = static::$connection_default;
$this->procedure = $procedure;
}

//<editor-fold desc="use">
public function use(string $database): Call {
$this->use = $database;
public function use(string $database, string $restore = ''): Call {
$this->use_before = $database;
$this->use_after = $restore;
return $this;
}
//</editor-fold>
Expand Down Expand Up @@ -325,10 +327,11 @@ public function execute(
}

// use
$use = strlen($this->use) ? "use `$this->use`;" : '';
$use_before = strlen($this->use_before) ? "use `$this->use_before`;" : '';
$use_after = strlen($this->use_after) ? "use `$this->use_after`;" : '';

// result
$query = $use . implode('', $variable) . "call `$this->procedure` (" . implode(',', $argument) . ');';
$query = $use_before . implode('', $variable) . "call `$this->procedure` (" . implode(',', $argument) . ');' . $use_after;

$this->mysqli->multi_query($query);
$results = [];
Expand Down

0 comments on commit 7744704

Please sign in to comment.