Code clean up for Basic Class clean up

Fix all other class code for calling former Basic class methods.
Also try to replace all remaining array() calls to [] type

Some docblock updates when missing or wrong set
This commit is contained in:
Clemens Schwaighofer
2021-06-14 15:00:02 +09:00
parent cb17b553b0
commit 3035287b5c
26 changed files with 228 additions and 199 deletions

View File

@@ -10,14 +10,6 @@
* table from the connected DB.
* you don't have to write any SQL queries, worry over update/insert
*
* PUBLIC VARIABLES
*
* PRIVATE VARIABLES
*
* PUBLIC METHOD:S
*
* PRIVATE METHOD:S
*
* HISTORY:
* 2019/9/11 (cs) error string 21->91, 22->92 for not overlapping with IO
* 2005/07/07 (cs) updated array class for postgres: set 0 & NULL if int field given, insert uses () values () syntax
@@ -105,11 +97,6 @@ class ArrayIO extends \CoreLibs\DB\IO
return $text;
}
// METHOD: convertEntities
// WAS : convert_entities
// PARAMS: string -> string to be changed
// RETURN: string -> altered string
// DESC : changeds all HTML entities into non HTML ones
/**
* changeds all HTML entities into non HTML ones
* @param string $text encoded html string
@@ -139,7 +126,7 @@ class ArrayIO extends \CoreLibs\DB\IO
}
// add output to internal error_msg
if ($write === true) {
$this->error_msg['db'] .= $string;
$this->__dbDebug('dbArray', $string);
}
return $string;
}
@@ -188,7 +175,7 @@ class ArrayIO extends \CoreLibs\DB\IO
* set this as new table array too
* @return array returns the table array that was deleted
*/
public function dbDelete($table_array = array())
public function dbDelete($table_array = [])
{
// is array and has values, override set and set new
if (is_array($table_array) && count($table_array)) {
@@ -247,7 +234,7 @@ class ArrayIO extends \CoreLibs\DB\IO
* @param array $table_array optional table array, overwrites internal set array
* @return array set table array with values
*/
public function dbRead($edit = false, $table_array = array())
public function dbRead($edit = false, $table_array = [])
{
// if array give, overrules internal array
if (is_array($table_array) && count($table_array)) {
@@ -320,7 +307,7 @@ class ArrayIO extends \CoreLibs\DB\IO
* @param array $table_array optional table array, overwrites internal one
* @return array table array or null
*/
public function dbWrite($addslashes = false, $table_array = array())
public function dbWrite($addslashes = false, $table_array = [])
{
if (is_array($table_array) && count($table_array)) {
$this->table_array = $table_array;

View File

@@ -278,7 +278,7 @@ class IO extends \CoreLibs\Basic
// other vars
private $nbsp = ''; // used by print_array recursion function
// error & warning id
// not error_id is defined in \CoreLibs\Basic
protected $error_id;
private $had_error;
private $warning_id;
private $had_warning;
@@ -535,7 +535,7 @@ class IO extends \CoreLibs\Basic
* @param string $type query identifier (Q, I, etc)
* @return void has no return
*/
private function __dbDebug(string $debug_id, string $error_string, string $id = '', string $type = ''): void
protected function __dbDebug(string $debug_id, string $error_string, string $id = '', string $type = ''): void
{
$prefix = '';
if ($id) {
@@ -562,7 +562,7 @@ class IO extends \CoreLibs\Basic
public function __dbError($cursor = false, string $msg = ''): void
{
$pg_error_string = '';
$where_called = (string)$this->getCallerMethod();
$where_called = (string)\CoreLibs\Debug\Support::getCallerMethod();
if ($cursor) {
$pg_error_string = $this->db_functions->__dbPrintError($cursor);
}
@@ -1115,7 +1115,7 @@ class IO extends \CoreLibs\Basic
$md5 = md5($query);
// pre declare array
if (!isset($this->cursor_ext[$md5])) {
$this->cursor_ext[$md5] = array(
$this->cursor_ext[$md5] = [
'query' => '',
'pos' => 0,
'cursor' => 0,
@@ -1123,7 +1123,7 @@ class IO extends \CoreLibs\Basic
'num_rows' => 0,
'num_fields' => 0,
'read_rows' => 0
);
];
}
// set the query
$this->cursor_ext[$md5]['query'] = $query;
@@ -1624,7 +1624,7 @@ class IO extends \CoreLibs\Basic
}
$result = $this->db_functions->__dbExecute($stm_name, $data);
if (!$result) {
$this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[$stm_name]['result'].']: '.$this->printAr($data));
$this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[$stm_name]['result'].']: '.\CoreLibs\Debug\Support::printAr($data));
$this->error_id = 22;
$this->__dbError($this->prepare_cursor[$stm_name]['result']);
$this->__dbDebug('db', '<span style="color: red;"><b>DB-Error</b> '.$stm_name.': Execution failed</span>', 'DB_ERROR');
@@ -1868,10 +1868,10 @@ class IO extends \CoreLibs\Basic
array $data = []
) {
if (!is_array($primary_key)) {
$primary_key = array(
$primary_key = [
'row' => $table.'_id',
'value' => $primary_key
);
];
} else {
if (!isset($primary_key['row'])) {
$primary_key['row'] = '';

View File

@@ -266,7 +266,7 @@ class PgSQL
if ($q = $this->__dbQuery($q)) {
list($id) = $this->__dbFetchArray($q);
} else {
$id = array(-1, $q);
$id = [-1, $q];
}
return $id;
}
@@ -444,7 +444,7 @@ class PgSQL
{
if (false === $limit) {
$limit = strlen($text) - 1;
$output = array();
$output = [];
}
if ('{}' != $text) {
do {