Compare commits

...

1 Commits

Author SHA1 Message Date
Clemens Schwaighofer
2635ccb82b edit.css: rename animation, Bug fix in DB\IO cursor_ext access and others
Make sure cursor_ext is set before we access it, else return null for
not set yet.
false for errors, else data value

Other class var access checks to be sure to never fail
2023-08-28 07:40:41 +09:00
2 changed files with 31 additions and 20 deletions

View File

@@ -377,7 +377,7 @@ input[type="text"]:focus, textarea:focus, select:focus {
border-top-color: rgba(3, 155, 229 ,1); border-top-color: rgba(3, 155, 229 ,1);
border-radius: 50%; border-radius: 50%;
display: inline-block; display: inline-block;
animation: rotate 600ms infinite linear; animation: progress-move 600ms infinite linear;
/* align */ /* align */
left: 0; left: 0;
top: 0; top: 0;
@@ -385,7 +385,7 @@ input[type="text"]:focus, textarea:focus, select:focus {
z-index: 1000; z-index: 1000;
} }
/* Animation for above progress */ /* Animation for above progress */
@keyframes rotate { @keyframes progress-move {
to { to {
transform: rotate(1turn) transform: rotate(1turn)
} }

View File

@@ -302,9 +302,9 @@ class IO
/** @var string */ /** @var string */
private string $to_encoding = ''; private string $to_encoding = '';
/** @var string the query string at the moment */ /** @var string the query string at the moment */
private string $query; private string $query = '';
/** @var array<mixed> current params for query */ /** @var array<mixed> current params for query */
private array $params; private array $params = [];
// only inside // only inside
// basic vars // basic vars
// the dbh handler, if disconnected by command is null, bool:false on error, // the dbh handler, if disconnected by command is null, bool:false on error,
@@ -344,7 +344,7 @@ class IO
// FOR BELOW: (This should be private and only readable through some method) // FOR BELOW: (This should be private and only readable through some method)
// cursor array for cached readings // cursor array for cached readings
/** @var array<string,mixed> extended cursoers string index with content */ /** @var array<string,mixed> extended cursoers string index with content */
private array $cursor_ext; private array $cursor_ext = [];
// per query vars // per query vars
/** @var \PgSql\Result|false actual cursor (DBH) */ /** @var \PgSql\Result|false actual cursor (DBH) */
private \PgSql\Result|false $cursor; private \PgSql\Result|false $cursor;
@@ -401,7 +401,7 @@ class IO
/** @var bool if we use RETURNING in the INSERT call */ /** @var bool if we use RETURNING in the INSERT call */
private bool $returning_id = false; private bool $returning_id = false;
/** @var string if a sync is running holds the hash key of the query */ /** @var string if a sync is running holds the hash key of the query */
private string $async_running; private string $async_running = '';
// logging class, must be public so settings can be changed // logging class, must be public so settings can be changed
/** @var \CoreLibs\Logging\Logging */ /** @var \CoreLibs\Logging\Logging */
public \CoreLibs\Logging\Logging $log; public \CoreLibs\Logging\Logging $log;
@@ -2687,7 +2687,7 @@ class IO
*/ */
public function dbGetCursor(): \PgSql\Result|false public function dbGetCursor(): \PgSql\Result|false
{ {
return $this->cursor; return $this->cursor ?? false;
} }
// *************************** // ***************************
@@ -2744,7 +2744,7 @@ class IO
} }
$query_hash = $this->dbGetQueryHash($query, $params); $query_hash = $this->dbGetQueryHash($query, $params);
if ( if (
is_array($this->cursor_ext) && !empty($this->cursor_ext) &&
isset($this->cursor_ext[$query_hash]) isset($this->cursor_ext[$query_hash])
) { ) {
if (empty($query_field)) { if (empty($query_field)) {
@@ -2763,9 +2763,9 @@ class IO
* @param string $query Query to find in cursor_ext * @param string $query Query to find in cursor_ext
* @param array<mixed> $params If the query is params type we need params * @param array<mixed> $params If the query is params type we need params
* data to create a unique call one, optional * data to create a unique call one, optional
* @return int|false query position (row pos), false on error * @return int|false|null query position (row pos), false on error
*/ */
public function dbGetCursorPos(string $query, array $params = []): int|false public function dbGetCursorPos(string $query, array $params = []): int|false|null
{ {
$this->__dbErrorReset(); $this->__dbErrorReset();
if (!$query) { if (!$query) {
@@ -2773,7 +2773,14 @@ class IO
return false; return false;
} }
$query_hash = $this->dbGetQueryHash($query, $params); $query_hash = $this->dbGetQueryHash($query, $params);
return (int)$this->cursor_ext[$query_hash]['pos']; if (
!empty($this->cursor_ext) &&
isset($this->cursor_ext[$query_hash])
) {
return (int)$this->cursor_ext[$query_hash]['pos'];
} else {
return null;
}
} }
/** /**
@@ -2782,9 +2789,9 @@ class IO
* @param string $query Query to find in cursor_ext * @param string $query Query to find in cursor_ext
* @param array<mixed> $params If the query is params type we need params * @param array<mixed> $params If the query is params type we need params
* data to create a unique call one, optional * data to create a unique call one, optional
* @return int|false numer of rows returned, false on error * @return int|false|null numer of rows returned, false on error
*/ */
public function dbGetCursorNumRows(string $query, array $params = []): int|false public function dbGetCursorNumRows(string $query, array $params = []): int|false|null
{ {
$this->__dbErrorReset(); $this->__dbErrorReset();
if (!$query) { if (!$query) {
@@ -2792,7 +2799,14 @@ class IO
return false; return false;
} }
$query_hash = $this->dbGetQueryHash($query, $params); $query_hash = $this->dbGetQueryHash($query, $params);
return (int)$this->cursor_ext[$query_hash]['num_rows']; if (
!empty($this->cursor_ext) &&
isset($this->cursor_ext[$query_hash])
) {
return (int)$this->cursor_ext[$query_hash]['num_rows'];
} else {
return null;
}
} }
// *************************** // ***************************
@@ -3194,7 +3208,7 @@ class IO
/** /**
* Returns the current async running query hash * Returns the current async running query hash
* *
* @return string Current async running query hash * @return string Current async running query hash, empty string for nothing
*/ */
public function dbGetAsyncRunning(): string public function dbGetAsyncRunning(): string
{ {
@@ -3829,7 +3843,7 @@ class IO
*/ */
public function dbGetNumRows(): ?int public function dbGetNumRows(): ?int
{ {
return $this->num_rows; return $this->num_rows ?? null;
} }
/** /**
@@ -3839,10 +3853,7 @@ class IO
*/ */
public function dbGetNumFields(): ?int public function dbGetNumFields(): ?int
{ {
if (!isset($this->num_fields)) { return $this->num_fields ?? null;
return null;
}
return $this->num_fields;
} }
/** /**