This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/add more connector tests (#56)
* Added support for Proxy connections * fix some bugs * testing nasty bugs in php * breaking build * fixing build * finished implementation of Counter * PSR fixes
- Loading branch information
1 parent
542a3ec
commit 4a7c8fb
Showing
12 changed files
with
192 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php // vim:ts=4:sw=4:et:fdm=marker | ||
|
||
namespace atk4\dsql; | ||
|
||
/** | ||
* @license MIT | ||
* @copyright Agile Toolkit (c) http://agiletoolkit.org/ | ||
*/ | ||
class Connection_Counter extends Connection_Proxy | ||
{ | ||
protected $callback = null; | ||
|
||
protected $selects = 0; | ||
protected $queries = 0; | ||
protected $expressions = 0; | ||
|
||
protected $rows = 0; | ||
|
||
public function iterate($ret) | ||
{ | ||
foreach ($ret as $key => $row) { | ||
$this->rows++; | ||
yield $key => $row; | ||
} | ||
} | ||
|
||
public function execute(Expression $expr) | ||
{ | ||
if ($expr instanceof Query) { | ||
$this->queries++; | ||
if ($expr->mode === 'select' || $expr->mode === null) { | ||
$this->selects++; | ||
} | ||
} else { | ||
$this->expressions++; | ||
} | ||
|
||
$ret = parent::execute($expr); | ||
|
||
|
||
return $this->iterate($ret); | ||
} | ||
public function __destruct() | ||
{ | ||
if ($this->callback) { | ||
$c = $this->callback; | ||
$c($this->selects, $this->rows, $this->queries, $this->expressions); | ||
} else { | ||
printf( | ||
"Queries: %3d, Selects: %3d, Rows fetched: %4d, Expressions %3d\n", | ||
$this->queries, | ||
$this->selects, | ||
$this->rows, | ||
$this->expressions | ||
); | ||
} | ||
|
||
|
||
|
||
return; | ||
|
||
$took = time() + microtime() - $this->start_time; | ||
|
||
|
||
return $ret; | ||
} | ||
} |
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,33 @@ | ||
<?php // vim:ts=4:sw=4:et:fdm=marker | ||
|
||
namespace atk4\dsql; | ||
|
||
/** | ||
* @license MIT | ||
* @copyright Agile Toolkit (c) http://agiletoolkit.org/ | ||
*/ | ||
class Connection_Proxy extends Connection | ||
{ | ||
public function connection() | ||
{ | ||
return $this->connection->connection(); | ||
} | ||
public function dsql($properties = []) | ||
{ | ||
$dsql = $this->connection->dsql($properties); | ||
$dsql->connection = $this; | ||
return $dsql; | ||
} | ||
|
||
public function expr($properties = [], $arguments = null) | ||
{ | ||
$expr = $this->connection->expr($properties, $arguments); | ||
$expr->connection = $this; | ||
return $expr; | ||
} | ||
|
||
public function execute(Expression $expr) | ||
{ | ||
return $this->connection->execute($expr); | ||
} | ||
} |
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
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