From b7f594e6830edf399d31c717850ed484e71fb542 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Tue, 22 Mar 2022 20:11:13 +0900 Subject: [PATCH] Fix, config master base style/js, fix DB\IO num rows DB\IO dbReturn also sets internal num_rows, num_fields, field_names so the normal dbGet* calls can be used after dbReturn call JAVASCRIPT/STYLESHEET in config.master is now override able from .env file. Others will follow --- www/admin/class_test.db.php | 5 ++++- www/composer.json | 5 +++-- www/configs/config.master.php | 4 ++-- www/includes/admin_header.php | 1 - www/lib/CoreLibs/DB/IO.php | 4 ++++ 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/www/admin/class_test.db.php b/www/admin/class_test.db.php index 1687ebc5..b092a298 100644 --- a/www/admin/class_test.db.php +++ b/www/admin/class_test.db.php @@ -69,6 +69,9 @@ $db->dbSetEncoding('SJIS'); print "ENCODING TEST: " . $db->dbVersionInfo('client_encoding') . "/" . $db->dbGetEncoding() . "
"; $db->dbResetEncoding(); +$res = $db->dbReturn("SELECT * FROM max_test"); +print "DB RETURN ROWS: " . $db->dbGetNumRows() . "
"; + while (is_array($res = $db->dbReturn("SELECT * FROM max_test", DbIo::USE_CACHE, true))) { print "UUD/TIME: " . $res['uid'] . "/" . $res['time'] . "
"; } @@ -277,7 +280,7 @@ print "Wrote to DB tabel $table with data " . print_r($data, true) . " and got p // return Array Test $query = "SELECT type, sdate, integer FROM foobar"; $data = $db->dbReturnArray($query, true); -print "Full foobar list:
" . print_r($data, true) . "

"; +print "Rows: " . $db->dbGetNumRows() . ", Full foobar list:
" . print_r($data, true) . "

"; // trigger a warning print "WARNING NEXT
"; diff --git a/www/composer.json b/www/composer.json index 25d18b3e..698da099 100644 --- a/www/composer.json +++ b/www/composer.json @@ -1,6 +1,7 @@ { - "name": "gullevek/corelibs", - "description": "CoreLibs", + "name": "gullevek/corelibs-dev", + "version": "dev-master", + "description": "CoreLibs: Development package", "type": "library", "authors": [ { diff --git a/www/configs/config.master.php b/www/configs/config.master.php index 597d52dc..0cca6b1c 100644 --- a/www/configs/config.master.php +++ b/www/configs/config.master.php @@ -274,8 +274,8 @@ define('G_TITLE', $_ENV['G_TITLE'] ?? ''); /************ STYLE SHEETS / JS **********/ define('ADMIN_STYLESHEET', 'edit.css'); define('ADMIN_JAVASCRIPT', 'edit.js'); -define('STYLESHEET', 'frontend.css'); -define('JAVASCRIPT', 'frontend.js'); +define('STYLESHEET', $_ENV['STYLESHEET'] ?? 'frontend.css'); +define('JAVASCRIPT', $_ENV['JAVASCRIPT'] ?? 'frontend.js'); // anything optional /************* INTERNAL ******************/ diff --git a/www/includes/admin_header.php b/www/includes/admin_header.php index be84f8b1..e694fb55 100644 --- a/www/includes/admin_header.php +++ b/www/includes/admin_header.php @@ -4,7 +4,6 @@ * AUTHOR: Clemens Schwaighofer * CREATED: 2008/08/01 * SHORT DESCRIPTION: -* URL redirect header * HISTORY: *********************************************************************/ diff --git a/www/lib/CoreLibs/DB/IO.php b/www/lib/CoreLibs/DB/IO.php index b0dca78b..c4254575 100644 --- a/www/lib/CoreLibs/DB/IO.php +++ b/www/lib/CoreLibs/DB/IO.php @@ -1786,9 +1786,12 @@ class IO // count the rows returned (if select) $this->cursor_ext[$query_hash]['num_rows'] = $this->db_functions->__dbNumRows($this->cursor_ext[$query_hash]['cursor']); + // also set last return + $this->num_rows = $this->cursor_ext[$query_hash]['num_rows']; // count the fields $this->cursor_ext[$query_hash]['num_fields'] = $this->db_functions->__dbNumFields($this->cursor_ext[$query_hash]['cursor']); + $this->num_fields = $this->cursor_ext[$query_hash]['num_fields']; // set field names $this->cursor_ext[$query_hash]['field_names'] = []; for ($i = 0; $i < $this->cursor_ext[$query_hash]['num_fields']; $i++) { @@ -1798,6 +1801,7 @@ class IO $i ); } + $this->field_names = $this->cursor_ext[$query_hash]['field_names']; // reset first call vars $this->cursor_ext[$query_hash]['firstcall'] = 0; // reset the internal pos counter