diff --git a/4dev/database/table/edit_group.sql b/4dev/database/table/edit_group.sql index 083e7fe4..26f1ceaf 100644 --- a/4dev/database/table/edit_group.sql +++ b/4dev/database/table/edit_group.sql @@ -10,6 +10,7 @@ CREATE TABLE edit_group ( edit_group_id SERIAL PRIMARY KEY, name VARCHAR, enabled SMALLINT NOT NULL DEFAULT 0, + deleted SMALLINT DEFAULT 0, edit_scheme_id INT, edit_access_right_id INT NOT NULL, alternative_acl JSONB, diff --git a/4dev/database/table/edit_user.sql b/4dev/database/table/edit_user.sql index 3cdd28aa..c7f7430c 100644 --- a/4dev/database/table/edit_user.sql +++ b/4dev/database/table/edit_user.sql @@ -16,6 +16,7 @@ CREATE TABLE edit_user ( first_name_furigana VARCHAR, last_name_furigana VARCHAR, enabled SMALLINT NOT NULL DEFAULT 0, + deleted SMALLINT NOT NULL DEFAULT 0, debug SMALLINT NOT NULL DEFAULT 0, db_debug SMALLINT NOT NULL DEFAULT 0, email VARCHAR, diff --git a/www/lib/CoreLibs/DB/IO.inc b/www/lib/CoreLibs/DB/IO.inc index d87cda1d..27c7b3ed 100644 --- a/www/lib/CoreLibs/DB/IO.inc +++ b/www/lib/CoreLibs/DB/IO.inc @@ -1259,9 +1259,10 @@ class IO extends \CoreLibs\Basic // WAS : db_fetch_array // PARAMS: cusors -> the cursor from db_exec or pg_query/pg_exec/mysql_query // if not set will use internal cursor, if not found, stops with 0 (error) + // assoc_only -> false is default, if true only assoc rows // RETURN: a mixed row // DESC : executes a cursor and returns the data, if no more data 0 will be returned - public function dbFetchArray($cursor = 0) + public function dbFetchArray($cursor = 0, $assoc_only = false) { // return false if no query or cursor set ... if (!$cursor) { @@ -1272,15 +1273,21 @@ class IO extends \CoreLibs\Basic $this->__dbError(); return false; } - return $this->__dbConvertEncoding($this->db_functions->__dbFetchArray($cursor)); + return $this->__dbConvertEncoding( + $this->db_functions->__dbFetchArray( + $cursor, + $this->db_functions->__dbResultType($assoc_only) + ) + ); } // METHOD: dbReturnRow // WAS : db_return_row // PARAMS: query -> the query to be executed + // assoc_only -> if true, only return assoc entry, else both (pgsql) // RETURN: mixed db result // DESC : returns the FIRST row of the given query - public function dbReturnRow($query) + public function dbReturnRow($query, $assoc_only = false) { if (!$query) { $this->error_id = 11; @@ -1294,7 +1301,7 @@ class IO extends \CoreLibs\Basic return false; } $cursor = $this->dbExec($query); - $result = $this->dbFetchArray($cursor); + $result = $this->dbFetchArray($cursor, $assoc_only); return $result; } diff --git a/www/lib/CoreLibs/DB/SQL/PgSQL.inc b/www/lib/CoreLibs/DB/SQL/PgSQL.inc index bc648c42..adc7fcc7 100644 --- a/www/lib/CoreLibs/DB/SQL/PgSQL.inc +++ b/www/lib/CoreLibs/DB/SQL/PgSQL.inc @@ -190,6 +190,9 @@ class PgSQL // DESC : wrapper for pg_fetch_array public function __dbFetchArray($cursor, $result_type = '') { + if ($result_type == true) { + $result_type = PGSQL_ASSOC; + } // result type is passed on as is [should be checked] if ($result_type) { return pg_fetch_array($cursor, null, $result_type); @@ -198,6 +201,18 @@ class PgSQL } } + // METHOD: __dbResultType + // PARAMS: true/false for ASSOC only or BOTH + // RETURN: PGSQL assoc type + // DESC : simple match up between assoc true/false + public function __dbResultType($assoc_type) + { + if ($assoc_type == true) { + return PGSQL_ASSOC; + } + return ''; // fallback to default + } + // METHOD: __dbFetchAll // WAS : _db_fetch_all // PARAMS: cursor