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
8 changed files
with
141 additions
and
26 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
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Nette Framework (https://nette.org) | ||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nette\Database\Drivers; | ||
|
||
use Nette; | ||
|
||
|
||
/** | ||
* PDO-based result-set driver. | ||
*/ | ||
class PdoResultDriver implements Nette\Database\ResultDriver | ||
{ | ||
private \PDOStatement $result; | ||
|
||
private PdoDriver $driver; | ||
|
||
|
||
public function __construct(\PDOStatement $result, PdoDriver $driver) | ||
{ | ||
$this->result = $result; | ||
$this->driver = $driver; | ||
} | ||
|
||
|
||
public function fetch(): ?array | ||
{ | ||
$data = $this->result->fetch(); | ||
if (!$data) { | ||
$this->result->closeCursor(); | ||
return null; | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
|
||
public function getColumnCount(): int | ||
{ | ||
return $this->result->columnCount(); | ||
} | ||
|
||
|
||
public function getRowCount(): int | ||
{ | ||
return $this->result->rowCount(); | ||
} | ||
|
||
|
||
public function getColumnTypes(): array | ||
{ | ||
return $this->driver->getColumnTypes($this->result); | ||
} | ||
|
||
|
||
public function getColumnMeta(int $col): array | ||
{ | ||
return $this->result->getColumnMeta($col); | ||
} | ||
|
||
|
||
public function getPdoStatement(): \PDOStatement | ||
{ | ||
return $this->result; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Nette Framework (https://nette.org) | ||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nette\Database; | ||
|
||
|
||
/** | ||
* Supplemental database driver for result-set. | ||
*/ | ||
interface ResultDriver | ||
{ | ||
/** | ||
* Fetches the row at current position and moves the internal cursor to the next position. | ||
*/ | ||
function fetch(): ?array; | ||
|
||
/** | ||
* Returns the number of columns in a result set. | ||
*/ | ||
function getColumnCount(): int; | ||
|
||
/** | ||
* Returns the number of rows in a result set. | ||
*/ | ||
function getRowCount(): int; | ||
|
||
/** | ||
* Returns associative array of detected types (IStructure::FIELD_*) in result set. | ||
*/ | ||
function getColumnTypes(): array; | ||
|
||
/** | ||
* Returns associative array of original table names. | ||
*/ | ||
function getColumnMeta(int $col): array; | ||
} |
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