CoreLibs update v8.1.2
This commit is contained in:
@@ -67,12 +67,30 @@ $q_db_ret = "SELECT * FROM test_db_return ORDER BY uid";
|
|||||||
|
|
||||||
RunningTime::hrRunningTime();
|
RunningTime::hrRunningTime();
|
||||||
|
|
||||||
|
$cache_flag = '[DEFAULT] NO_CACHE (0)';
|
||||||
|
print "dbReturn '" . $cache_flag . "'/Default: " . $q_db_ret . "<br>";
|
||||||
|
// Do twice
|
||||||
|
for ($i = 1; $i <= 6; $i++) {
|
||||||
|
$res = $db->dbReturn($q_db_ret);
|
||||||
|
print $i . ") " . $cache_flag . ": "
|
||||||
|
. "res: " . (is_bool($res) ?
|
||||||
|
"<b>Bool:</b> " . $db->log->prBl($res) :
|
||||||
|
(is_array($res) ?
|
||||||
|
"Array: " . $db->log->prBl(is_array($res)) : '{-}')
|
||||||
|
) . ", "
|
||||||
|
. "cursor_ext: <pre>" . Support::printAr(
|
||||||
|
SetVarType::setArray($db->dbGetCursorExt($q_db_ret))
|
||||||
|
) . "</pre>";
|
||||||
|
print "Run time: " . RunningTime::hrRunningTime() . "<br>";
|
||||||
|
}
|
||||||
|
print "<hr>";
|
||||||
|
|
||||||
$cache_flag = 'USE_CACHE (0)';
|
$cache_flag = 'USE_CACHE (0)';
|
||||||
print "dbReturn '" . $cache_flag . "'/Default: " . $q_db_ret . "<br>";
|
print "dbReturn '" . $cache_flag . "'/Default: " . $q_db_ret . "<br>";
|
||||||
// SINGLE read on multi row return
|
// SINGLE read on multi row return
|
||||||
// Do twice
|
// Do twice
|
||||||
for ($i = 1; $i <= 6; $i++) {
|
for ($i = 1; $i <= 6; $i++) {
|
||||||
$res = $db->dbReturn($q_db_ret);
|
$res = $db->dbReturn($q_db_ret, $db::USE_CACHE);
|
||||||
print $i . ") " . $cache_flag . ": "
|
print $i . ") " . $cache_flag . ": "
|
||||||
. "res: " . (is_bool($res) ?
|
. "res: " . (is_bool($res) ?
|
||||||
"<b>Bool:</b> " . $db->log->prBl($res) :
|
"<b>Bool:</b> " . $db->log->prBl($res) :
|
||||||
|
|||||||
@@ -314,6 +314,46 @@ print "EOM STRING EXEC RETURN TEST: " . print_r(
|
|||||||
)
|
)
|
||||||
) . "<br>";
|
) . "<br>";
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
|
// binary insert tests
|
||||||
|
$filename = $db->dbEscapeLiteral('class_test.db.php');
|
||||||
|
$rand_bin_uid = $db->dbEscapeLiteral(\CoreLibs\Create\Uids::uniqIdShort());
|
||||||
|
$binary_data = $db->dbEscapeBytea(file_get_contents('class_test.db.php') ?: '');
|
||||||
|
$query = <<<EOM
|
||||||
|
INSERT INTO binary_test (
|
||||||
|
filename, uid, binary_data
|
||||||
|
) VALUES (
|
||||||
|
$filename, $rand_bin_uid, '$binary_data'
|
||||||
|
)
|
||||||
|
EOM;
|
||||||
|
$status = $db->dbExec($query);
|
||||||
|
$__last_insert_id = $db->dbGetInsertPK();
|
||||||
|
print "BINARY DATA INSERT: "
|
||||||
|
. Support::printToString($status) . " |<br>"
|
||||||
|
. " |<br>"
|
||||||
|
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | "
|
||||||
|
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||||
|
. "RETURNING RETURN: " . print_r($db->dbGetReturningArray(), true)
|
||||||
|
. "ERROR: " . $db->dbGetLastError(true) . "<br>";
|
||||||
|
|
||||||
|
echo "<b>*</b><br>";
|
||||||
|
$query = <<<EOM
|
||||||
|
INSERT INTO binary_test (
|
||||||
|
filename, uid, binary_data
|
||||||
|
) VALUES (
|
||||||
|
$1, $2, $3
|
||||||
|
)
|
||||||
|
EOM;
|
||||||
|
$status = $db->dbExecParams($query, [$filename, $rand_bin_uid, $binary_data]);
|
||||||
|
$__last_insert_id = $db->dbGetInsertPK();
|
||||||
|
print "BINARY DATA INSERT PARAMS: "
|
||||||
|
. Support::printToString($status) . " |<br>"
|
||||||
|
. " |<br>"
|
||||||
|
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | "
|
||||||
|
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||||
|
. "RETURNING RETURN: " . print_r($db->dbGetReturningArray(), true)
|
||||||
|
. "ERROR: " . $db->dbGetLastError(true) . "<br>";
|
||||||
|
|
||||||
|
echo "<hr>";
|
||||||
|
|
||||||
// returning test with multiple entries
|
// returning test with multiple entries
|
||||||
// $status = $db->db_exec(
|
// $status = $db->db_exec(
|
||||||
|
|||||||
4
www/composer.lock
generated
4
www/composer.lock
generated
@@ -8,11 +8,11 @@
|
|||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "egrajp/corelibs-composer-all",
|
"name": "egrajp/corelibs-composer-all",
|
||||||
"version": "dev-master",
|
"version": "dev-development",
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All",
|
"url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All",
|
||||||
"reference": "4a246bec5f8e9944a77e1997f0f40c7f4f936528"
|
"reference": "0e6a43a2c286dcd78720287c344891db633edbfd"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.1"
|
"php": ">=8.1"
|
||||||
|
|||||||
6
www/vendor/composer/installed.json
vendored
6
www/vendor/composer/installed.json
vendored
@@ -2,12 +2,12 @@
|
|||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "egrajp/corelibs-composer-all",
|
"name": "egrajp/corelibs-composer-all",
|
||||||
"version": "dev-master",
|
"version": "dev-development",
|
||||||
"version_normalized": "dev-master",
|
"version_normalized": "dev-development",
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All",
|
"url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All",
|
||||||
"reference": "4a246bec5f8e9944a77e1997f0f40c7f4f936528"
|
"reference": "0e6a43a2c286dcd78720287c344891db633edbfd"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.1"
|
"php": ">=8.1"
|
||||||
|
|||||||
6
www/vendor/composer/installed.php
vendored
6
www/vendor/composer/installed.php
vendored
@@ -11,9 +11,9 @@
|
|||||||
),
|
),
|
||||||
'versions' => array(
|
'versions' => array(
|
||||||
'egrajp/corelibs-composer-all' => array(
|
'egrajp/corelibs-composer-all' => array(
|
||||||
'pretty_version' => 'dev-master',
|
'pretty_version' => 'dev-development',
|
||||||
'version' => 'dev-master',
|
'version' => 'dev-development',
|
||||||
'reference' => '4a246bec5f8e9944a77e1997f0f40c7f4f936528',
|
'reference' => '0e6a43a2c286dcd78720287c344891db633edbfd',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../egrajp/corelibs-composer-all',
|
'install_path' => __DIR__ . '/../egrajp/corelibs-composer-all',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
8.1.0
|
8.1.1
|
||||||
|
|||||||
@@ -1821,7 +1821,7 @@ class IO
|
|||||||
* Wrapper for dbReturnParams
|
* Wrapper for dbReturnParams
|
||||||
*
|
*
|
||||||
* @param string $query Query string
|
* @param string $query Query string
|
||||||
* @param int $cache reset status: default: USE_CACHE
|
* @param int $cache reset status: default: NO_CACHE
|
||||||
* USE_CACHE/0: normal read from cache on second run
|
* USE_CACHE/0: normal read from cache on second run
|
||||||
* READ_NEW/1: write to cache, clean before new run
|
* READ_NEW/1: write to cache, clean before new run
|
||||||
* CLEAR_CACHE/2: write cache, clean after finished
|
* CLEAR_CACHE/2: write cache, clean after finished
|
||||||
@@ -1833,7 +1833,7 @@ class IO
|
|||||||
*/
|
*/
|
||||||
public function dbReturn(
|
public function dbReturn(
|
||||||
string $query,
|
string $query,
|
||||||
int $cache = self::USE_CACHE,
|
int $cache = self::NO_CACHE,
|
||||||
bool $assoc_only = false
|
bool $assoc_only = false
|
||||||
): array|false {
|
): array|false {
|
||||||
return $this->dbReturnParams($query, [], $cache, $assoc_only);
|
return $this->dbReturnParams($query, [], $cache, $assoc_only);
|
||||||
@@ -1856,7 +1856,7 @@ class IO
|
|||||||
*
|
*
|
||||||
* @param string $query Query string
|
* @param string $query Query string
|
||||||
* @param array<mixed> $params Query parameters
|
* @param array<mixed> $params Query parameters
|
||||||
* @param int $cache reset status: default: USE_CACHE
|
* @param int $cache reset status: default: NO_CACHE
|
||||||
* USE_CACHE/0: normal read from cache on second run
|
* USE_CACHE/0: normal read from cache on second run
|
||||||
* READ_NEW/1: write to cache, clean before new run
|
* READ_NEW/1: write to cache, clean before new run
|
||||||
* CLEAR_CACHE/2: write cache, clean after finished
|
* CLEAR_CACHE/2: write cache, clean after finished
|
||||||
@@ -1868,7 +1868,7 @@ class IO
|
|||||||
public function dbReturnParams(
|
public function dbReturnParams(
|
||||||
string $query,
|
string $query,
|
||||||
array $params = [],
|
array $params = [],
|
||||||
int $cache = self::USE_CACHE,
|
int $cache = self::NO_CACHE,
|
||||||
bool $assoc_only = false
|
bool $assoc_only = false
|
||||||
): array|false {
|
): array|false {
|
||||||
$this->__dbErrorReset();
|
$this->__dbErrorReset();
|
||||||
|
|||||||
@@ -2142,7 +2142,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
return [
|
return [
|
||||||
// *** READ STEP BY STEP
|
// *** READ STEP BY STEP
|
||||||
// default cache: USE_CACHE
|
// default cache: USE_CACHE
|
||||||
'valid select, default cache settings' => [
|
'valid select, default cache settings (NO_CACHE)' => [
|
||||||
// 0-3
|
// 0-3
|
||||||
$read_query,
|
$read_query,
|
||||||
null,
|
null,
|
||||||
@@ -2156,9 +2156,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
// check cursor_ext
|
// check cursor_ext
|
||||||
[
|
[
|
||||||
'cursor' => 'PgSql\Result',
|
'cursor' => 'PgSql\Result',
|
||||||
'data' => [
|
'data' => [],
|
||||||
0 => $row_a,
|
|
||||||
],
|
|
||||||
'field_names' => [
|
'field_names' => [
|
||||||
'row_int',
|
'row_int',
|
||||||
'uid'
|
'uid'
|
||||||
@@ -2173,9 +2171,9 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
'query' => $read_query,
|
'query' => $read_query,
|
||||||
'params' => [],
|
'params' => [],
|
||||||
'read_rows' => 1,
|
'read_rows' => 1,
|
||||||
'cache_flag' => \CoreLibs\DB\IO::USE_CACHE,
|
'cache_flag' => \CoreLibs\DB\IO::NO_CACHE,
|
||||||
'assoc_flag' => false,
|
'assoc_flag' => false,
|
||||||
'cached' => true,
|
'cached' => false,
|
||||||
'finished' => false,
|
'finished' => false,
|
||||||
'read_finished' => false,
|
'read_finished' => false,
|
||||||
'db_read_finished' => false,
|
'db_read_finished' => false,
|
||||||
@@ -2190,10 +2188,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
],
|
],
|
||||||
'cursor' => [
|
'cursor' => [
|
||||||
'cursor' => 'PgSql\Result',
|
'cursor' => 'PgSql\Result',
|
||||||
'data' => [
|
'data' => [],
|
||||||
0 => $row_a,
|
|
||||||
1 => $row_b,
|
|
||||||
],
|
|
||||||
'field_names' => [
|
'field_names' => [
|
||||||
'row_int',
|
'row_int',
|
||||||
'uid'
|
'uid'
|
||||||
@@ -2208,9 +2203,9 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
'query' => $read_query,
|
'query' => $read_query,
|
||||||
'params' => [],
|
'params' => [],
|
||||||
'read_rows' => 2,
|
'read_rows' => 2,
|
||||||
'cache_flag' => \CoreLibs\DB\IO::USE_CACHE,
|
'cache_flag' => \CoreLibs\DB\IO::NO_CACHE,
|
||||||
'assoc_flag' => false,
|
'assoc_flag' => false,
|
||||||
'cached' => true,
|
'cached' => false,
|
||||||
'finished' => false,
|
'finished' => false,
|
||||||
'read_finished' => true,
|
'read_finished' => true,
|
||||||
'db_read_finished' => true,
|
'db_read_finished' => true,
|
||||||
@@ -2221,10 +2216,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
'data' => false,
|
'data' => false,
|
||||||
'cursor' => [
|
'cursor' => [
|
||||||
'cursor' => 1,
|
'cursor' => 1,
|
||||||
'data' => [
|
'data' => [],
|
||||||
0 => $row_a,
|
|
||||||
1 => $row_b,
|
|
||||||
],
|
|
||||||
'field_names' => [
|
'field_names' => [
|
||||||
'row_int',
|
'row_int',
|
||||||
'uid'
|
'uid'
|
||||||
@@ -2239,9 +2231,9 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
'query' => $read_query,
|
'query' => $read_query,
|
||||||
'params' => [],
|
'params' => [],
|
||||||
'read_rows' => 2,
|
'read_rows' => 2,
|
||||||
'cache_flag' => \CoreLibs\DB\IO::USE_CACHE,
|
'cache_flag' => \CoreLibs\DB\IO::NO_CACHE,
|
||||||
'assoc_flag' => false,
|
'assoc_flag' => false,
|
||||||
'cached' => true,
|
'cached' => false,
|
||||||
'finished' => true,
|
'finished' => true,
|
||||||
'read_finished' => true,
|
'read_finished' => true,
|
||||||
'db_read_finished' => true,
|
'db_read_finished' => true,
|
||||||
@@ -2811,13 +2803,50 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
],
|
],
|
||||||
// *** READ AS LOOP
|
// *** READ AS LOOP
|
||||||
// from here on a complex read all full tests
|
// from here on a complex read all full tests
|
||||||
'valid select, full read DEFAULT CACHE' => [
|
'valid select, full read, default cache settings (NO CACHE)' => [
|
||||||
$read_query,
|
$read_query,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
[$row_a, $row_b,],
|
[$row_a, $row_b,],
|
||||||
false,
|
false,
|
||||||
|
[
|
||||||
|
'cursor' => 1,
|
||||||
|
'data' => [],
|
||||||
|
'field_names' => [
|
||||||
|
'row_int',
|
||||||
|
'uid'
|
||||||
|
],
|
||||||
|
'field_types' => [
|
||||||
|
'int4',
|
||||||
|
'varchar'
|
||||||
|
],
|
||||||
|
'num_fields' => 2,
|
||||||
|
'num_rows' => 2,
|
||||||
|
'pos' => 0,
|
||||||
|
'query' => $read_query,
|
||||||
|
'params' => [],
|
||||||
|
'read_rows' => 2,
|
||||||
|
'cache_flag' => \CoreLibs\DB\IO::NO_CACHE,
|
||||||
|
'assoc_flag' => false,
|
||||||
|
'cached' => false,
|
||||||
|
'finished' => true,
|
||||||
|
'read_finished' => true,
|
||||||
|
'db_read_finished' => true,
|
||||||
|
],
|
||||||
|
[],
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
$insert_query
|
||||||
|
],
|
||||||
|
// USE CACHE
|
||||||
|
'valid select, full read, USE CACHE' => [
|
||||||
|
$read_query,
|
||||||
|
null,
|
||||||
|
\CoreLibs\DB\IO::USE_CACHE,
|
||||||
|
null,
|
||||||
|
[$row_a, $row_b,],
|
||||||
|
false,
|
||||||
[
|
[
|
||||||
'cursor' => 1,
|
'cursor' => 1,
|
||||||
'data' => [
|
'data' => [
|
||||||
@@ -2851,7 +2880,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
$insert_query
|
$insert_query
|
||||||
],
|
],
|
||||||
// READ_NEW
|
// READ_NEW
|
||||||
'valid select, full read READ NEW' => [
|
'valid select, full read, READ NEW' => [
|
||||||
$read_query,
|
$read_query,
|
||||||
null,
|
null,
|
||||||
\CoreLibs\DB\IO::READ_NEW,
|
\CoreLibs\DB\IO::READ_NEW,
|
||||||
@@ -2891,7 +2920,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
$insert_query
|
$insert_query
|
||||||
],
|
],
|
||||||
// CLEAR_CACHE
|
// CLEAR_CACHE
|
||||||
'valid select, full read CLEAR CACHE' => [
|
'valid select, full read, CLEAR CACHE' => [
|
||||||
$read_query,
|
$read_query,
|
||||||
null,
|
null,
|
||||||
\CoreLibs\DB\IO::CLEAR_CACHE,
|
\CoreLibs\DB\IO::CLEAR_CACHE,
|
||||||
@@ -2928,7 +2957,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
'',
|
'',
|
||||||
$insert_query
|
$insert_query
|
||||||
],
|
],
|
||||||
'valid select, full read NO CACHE' => [
|
'valid select, full read, NO CACHE' => [
|
||||||
$read_query,
|
$read_query,
|
||||||
null,
|
null,
|
||||||
\CoreLibs\DB\IO::NO_CACHE,
|
\CoreLibs\DB\IO::NO_CACHE,
|
||||||
@@ -3070,7 +3099,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
* @covers ::dbCursorPos
|
* @covers ::dbCursorPos
|
||||||
* @covers ::dbCursorNumRows
|
* @covers ::dbCursorNumRows
|
||||||
* @dataProvider dbReturnProvider
|
* @dataProvider dbReturnProvider
|
||||||
* @testdox dbReturn Read Frist $read_first_only only and cache $flag_cache and assoc $flag_assoc with (Warning: $warning/Error: $error) [$_dataName]
|
* @testdox dbReturn Read First $read_first_only only and cache $flag_cache and assoc $flag_assoc with (Warning: $warning/Error: $error) [$_dataName]
|
||||||
*
|
*
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @param array<mixed>|null $params
|
* @param array<mixed>|null $params
|
||||||
@@ -4358,7 +4387,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
// NOTE if there are different INSERTS before the primary keys
|
// NOTE if there are different INSERTS before the primary keys
|
||||||
// will not match anymore. Must be updated by hand
|
// will not match anymore. Must be updated by hand
|
||||||
// IMPORTANT: if this is stand alone the primary key will not match and fail
|
// IMPORTANT: if this is stand alone the primary key will not match and fail
|
||||||
$table_with_primary_key_id = 66;
|
$table_with_primary_key_id = 68;
|
||||||
// 0: query + returning
|
// 0: query + returning
|
||||||
// 1: params
|
// 1: params
|
||||||
// 1: pk name for db exec
|
// 1: pk name for db exec
|
||||||
|
|||||||
Reference in New Issue
Block a user