Skip to content

Commit

Permalink
result WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Sep 3, 2024
1 parent a39fe2b commit b5718be
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/Dibi/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ final public function nativeQuery(#[Language('SQL')] string $sql): Result
throw $e;
}

$res = $this->createResultSet($res ?: new Drivers\NoDataResult(max(0, $this->driver->getAffectedRows())));
$res = $this->createResultSet($res ?: new Drivers\Dummy\Result(max(0, $this->driver->getAffectedRows())));
if ($event) {
$this->onEvent($event->done($res));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

declare(strict_types=1);

namespace Dibi\Drivers;
namespace Dibi\Drivers\Dummy;

use Dibi\Drivers;


/**
* The driver for no result set.
*/
class NoDataResult implements Result
class Result implements Drivers\Result
{
private int $rows;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@

declare(strict_types=1);

namespace Dibi\Drivers;
namespace Dibi\Drivers\Firebird;

use Dibi;
use Dibi\Drivers;
use Dibi\Drivers\FirebirdDriver;
use Dibi\Helpers;


/**
* The driver for Firebird/InterBase result set.
*/
class FirebirdResult implements Result
class Result implements Drivers\Result
{
/** @var resource */
private $resultSet;
Expand Down
5 changes: 3 additions & 2 deletions src/Dibi/Drivers/FirebirdDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Dibi;
use Dibi\Drivers\Engines\FirebirdEngine;
use Dibi\Drivers\Firebird\Firebird;
use Dibi\Helpers;


Expand Down Expand Up @@ -210,9 +211,9 @@ public function getReflector(): Engine
* Result set driver factory.
* @param resource $resource
*/
public function createResultDriver($resource): FirebirdResult
public function createResultDriver($resource): Firebird
{
return new FirebirdResult($resource);
return new Firebird($resource);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@

declare(strict_types=1);

namespace Dibi\Drivers;
namespace Dibi\Drivers\MySQLi;

use Dibi;
use Dibi\Drivers;


/**
* The driver for MySQL result set.
*/
class MySqliResult implements Result
class Result implements Drivers\Result
{
private \mysqli_result $resultSet;
private bool $buffered;
Expand Down
5 changes: 3 additions & 2 deletions src/Dibi/Drivers/MySqliDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Dibi;
use Dibi\Drivers\Engines\MySQLEngine;
use Dibi\Drivers\MySQLi\Result;


/**
Expand Down Expand Up @@ -273,9 +274,9 @@ public function getReflector(): Engine
/**
* Result set driver factory.
*/
public function createResultDriver(\mysqli_result $result): MySqliResult
public function createResultDriver(\mysqli_result $result): Result
{
return new MySqliResult($result, $this->buffered);
return new Result($result, $this->buffered);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@

declare(strict_types=1);

namespace Dibi\Drivers;
namespace Dibi\Drivers\OCI8;

use Dibi;
use Dibi\Drivers;


/**
* The driver for Oracle result set.
*/
class OracleResult implements Result
class Result implements Drivers\Result
{
/** @var resource */
private $resultSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@

declare(strict_types=1);

namespace Dibi\Drivers;
namespace Dibi\Drivers\ODBC;

use Dibi;
use Dibi\Drivers;


/**
* The driver interacting with result set via ODBC connections.
*/
class OdbcResult implements Result
class Result implements Drivers\Result
{
/** @var resource */
private $resultSet;
Expand Down
5 changes: 3 additions & 2 deletions src/Dibi/Drivers/OdbcDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Dibi;
use Dibi\Drivers\Engines\ODBCEngine;
use Dibi\Drivers\ODBC\Result;


/**
Expand Down Expand Up @@ -186,9 +187,9 @@ public function getReflector(): Engine
* Result set driver factory.
* @param resource $resource
*/
public function createResultDriver($resource): OdbcResult
public function createResultDriver($resource): Result
{
return new OdbcResult($resource);
return new Result($resource);
}


Expand Down
5 changes: 3 additions & 2 deletions src/Dibi/Drivers/OracleDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Dibi;
use Dibi\Drivers\Engines\OracleEngine;
use Dibi\Drivers\OCI8\Result;


/**
Expand Down Expand Up @@ -200,9 +201,9 @@ public function getReflector(): Engine
* Result set driver factory.
* @param resource $resource
*/
public function createResultDriver($resource): OracleResult
public function createResultDriver($resource): Result
{
return new OracleResult($resource);
return new Result($resource);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@

declare(strict_types=1);

namespace Dibi\Drivers;
namespace Dibi\Drivers\PDO;

use Dibi;
use Dibi\Drivers;
use Dibi\Helpers;
use PDO;


/**
* The driver for PDO result set.
*/
class PdoResult implements Result
class Result implements Drivers\Result
{
private ?\PDOStatement $resultSet;
private string $driverName;
Expand Down
5 changes: 3 additions & 2 deletions src/Dibi/Drivers/PdoDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Dibi\Drivers\Engines\PostgreSQLEngine;
use Dibi\Drivers\Engines\SQLiteEngine;
use Dibi\Drivers\Engines\SQLServerEngine;
use Dibi\Drivers\PDO\Result;
use Dibi\Helpers;
use PDO;

Expand Down Expand Up @@ -195,9 +196,9 @@ public function getReflector(): Engine
/**
* Result set driver factory.
*/
public function createResultDriver(\PDOStatement $result): PdoResult
public function createResultDriver(\PDOStatement $result): Result
{
return new PdoResult($result, $this->driverName);
return new Result($result, $this->driverName);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@

declare(strict_types=1);

namespace Dibi\Drivers;
namespace Dibi\Drivers\PgSQL;

use Dibi\Drivers;
use Dibi\Helpers;
use PgSql;


/**
* The driver for PostgreSQL result set.
*/
class PostgreResult implements Result
class Result implements Drivers\Result
{
/** @var resource|PgSql\Result */
private $resultSet;
Expand Down
5 changes: 3 additions & 2 deletions src/Dibi/Drivers/PostgreDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Dibi;
use Dibi\Drivers\Engines\PostgreSQLEngine;
use Dibi\Drivers\PgSQL\Result;
use Dibi\Helpers;
use PgSql;

Expand Down Expand Up @@ -246,9 +247,9 @@ public function getReflector(): Engine
* Result set driver factory.
* @param resource $resource
*/
public function createResultDriver($resource): PostgreResult
public function createResultDriver($resource): Result
{
return new PostgreResult($resource);
return new Result($resource);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@

declare(strict_types=1);

namespace Dibi\Drivers;
namespace Dibi\Drivers\SQLSrv;

use Dibi;
use Dibi\Drivers;


/**
* The driver for Microsoft SQL Server and SQL Azure result set.
*/
class SqlsrvResult implements Result
class Result implements Drivers\Result
{
/** @var resource */
private $resultSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@

declare(strict_types=1);

namespace Dibi\Drivers;
namespace Dibi\Drivers\SQLite3;

use Dibi;
use Dibi\Drivers;
use Dibi\Helpers;


/**
* The driver for SQLite result set.
*/
class SqliteResult implements Result
class Result implements Drivers\Result
{
private \SQLite3Result $resultSet;

Expand Down
18 changes: 0 additions & 18 deletions src/Dibi/Drivers/Sqlite3Result.php

This file was deleted.

5 changes: 3 additions & 2 deletions src/Dibi/Drivers/SqliteDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Dibi;
use Dibi\Drivers\Engines\SQLiteEngine;
use Dibi\Drivers\SQLite3\Result;
use Dibi\Helpers;
use SQLite3;

Expand Down Expand Up @@ -187,9 +188,9 @@ public function getReflector(): Engine
/**
* Result set driver factory.
*/
public function createResultDriver(\SQLite3Result $result): SqliteResult
public function createResultDriver(\SQLite3Result $result): Result
{
return new SqliteResult($result);
return new Result($result);
}


Expand Down
5 changes: 3 additions & 2 deletions src/Dibi/Drivers/SqlsrvDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Dibi;
use Dibi\Drivers\Engines\SQLServerEngine;
use Dibi\Drivers\SQLSrv\Result;
use Dibi\Helpers;


Expand Down Expand Up @@ -184,9 +185,9 @@ public function getReflector(): Engine
* Result set driver factory.
* @param resource $resource
*/
public function createResultDriver($resource): SqlsrvResult
public function createResultDriver($resource): Result
{
return new SqlsrvResult($resource);
return new Result($resource);
}


Expand Down
3 changes: 2 additions & 1 deletion tests/dibi/Fluent.fetch.limit.mssql.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use Dibi\Drivers\SQLSrv\Result;
use Tester\Assert;

require __DIR__ . '/bootstrap.php';
Expand All @@ -26,7 +27,7 @@ class MockDriver extends Dibi\Drivers\SqlsrvDriver
}


class MockResult extends Dibi\Drivers\SqlsrvResult
class MockResult extends Result
{
public function __construct()
{
Expand Down

0 comments on commit b5718be

Please sign in to comment.