Skip to content

Commit 746e91e

Browse files
committed
Overwrite rdbms.DBConnection::toString()
Fixes #50
1 parent 6f06630 commit 746e91e

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ RDBMS support for the XP Framework: MySQL, Sybase, MSSQL, PostgreSQL, SQLite3, I
33

44
## ?.?.? / ????-??-??
55

6+
## 13.0.4 / 2022-07-07
7+
8+
* Fixed #50: *TypeError (get_resource_type(): Argument #1 ($resource)
9+
must be of type resource, SQLite3 given)*
10+
(@thekid)
611
* Fixed #51: *Warning: Return type of rdbms\ResultSet::getIterator()*
712
(@thekid)
813

src/main/php/rdbms/DBConnection.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function toString() {
6363
nameof($this),
6464
$this->dsn->asString(),
6565
$this->tz ? ', tz='.$this->tz->toString() : '',
66-
$this->handle ? ', conn='.get_resource_type($this->handle).' #'.(int)$this->handle : ''
66+
$this->handle ? ', conn='.$this->hashCode() : ''
6767
);
6868
}
6969

src/main/php/rdbms/sqlite3/SQLite3Connection.class.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,17 @@ public function commit($name) {
199199
$this->transaction--;
200200
return true;
201201
}
202+
203+
/** @return string */
204+
public function hashCode() {
205+
if (PHP_VERSION_ID >= 70200) {
206+
$id= spl_object_id($this->handle);
207+
} else {
208+
ob_start();
209+
var_dump($this->handle);
210+
sscanf(ob_get_contents(), 'object(%*[^)])#%d', $id);
211+
ob_get_clean();
212+
}
213+
return 'sqlite #'.$id;
214+
}
202215
}

0 commit comments

Comments
 (0)