Skip to content

Commit

Permalink
Implement and test execute from file method
Browse files Browse the repository at this point in the history
  • Loading branch information
ilijastuden committed Feb 8, 2017
1 parent dc42d21 commit ff31138
Show file tree
Hide file tree
Showing 4 changed files with 831 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Connection/MysqliConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,28 @@ public function inTransaction()
return $this->transaction_level > 0;
}

/**
* @param string $file_path
*/
public function executeFromFile($file_path)
{
if (!is_file($file_path)) {
throw new RuntimeException('File not found');
}

if ($this->link->multi_query(file_get_contents($file_path))) {
do {
if ($result = $this->link->store_result()) {
$result->free();
}

if (!$this->link->more_results()) {
break;
}
} while ($this->link->next_result());
}
}

/**
* {@inheritdoc}
*/
Expand Down
5 changes: 5 additions & 0 deletions src/ConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ public function rollback();
*/
public function inTransaction();

/**
* @param string $file_path
*/
public function executeFromFile($file_path);

/**
* @param string $database_name
* @return bool
Expand Down
Loading

0 comments on commit ff31138

Please sign in to comment.