From be9d2177320158a13e97e41616989358328d21b6 Mon Sep 17 00:00:00 2001 From: "stephan.kasdorf" Date: Tue, 3 Dec 2024 11:12:24 +0100 Subject: [PATCH] Add return type and values for update methods. The methods `updateRowByFieldWhere` and `updateColumnByFieldWhere` in `mysql.db.php` and `pdo.php` now have a `bool` return type and explicitly return the result of the database operations. This change improves code readability and enforces consistent function outputs, aiding in better error handling and debugging. --- core/a/mysql.db.php | 5 +++-- core/c/pdo.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/a/mysql.db.php b/core/a/mysql.db.php index 0631350..d8eb0da 100644 --- a/core/a/mysql.db.php +++ b/core/a/mysql.db.php @@ -151,10 +151,11 @@ abstract class Db implements IDb * @param bool $wherevalue * @param bool $rowfield * @param bool $rowvalue + * @return bool */ - public function updateRowByFieldWhere( $wherefield = false, $wherevalue = false, $rowfield = false, $rowvalue = false ) + public function updateRowByFieldWhere( $wherefield = false, $wherevalue = false, $rowfield = false, $rowvalue = false ): bool { - Pdo::updateColumnByFieldWhere( self::$table['table'], $rowfield, $rowvalue, $wherefield, $wherevalue ); + return Pdo::updateColumnByFieldWhere( self::$table['table'], $rowfield, $rowvalue, $wherefield, $wherevalue ); } /** diff --git a/core/c/pdo.php b/core/c/pdo.php index 511c764..3223bab 100755 --- a/core/c/pdo.php +++ b/core/c/pdo.php @@ -166,19 +166,20 @@ final class pdo extends Mysql implements IPdo * @param string $parameter_name * @param string $field_name * @param string $where_value + * @return bool */ public static function updateColumnByFieldWhere( $tablename = self::PLACE_TABLE_NAME, $column_name = IMysql::PLACE_COLUMN_NAME, $parameter_name = IMysql::PLACE_SEARCH_TERM, $field_name = IMysql::PLACE_FIELD_NAME, - $where_value = IMysql::PLACE_WHERE_VALUE ) + $where_value = IMysql::PLACE_WHERE_VALUE ): bool { $statement = parent::getInstance( self::getSettingsSection() )->getConn(); $query = "UPDATE " . $tablename . " SET " . $column_name . " = :" . $column_name . " WHERE " . $field_name . " = :". $field_name; $insert = $statement->prepare($query); $insert->bindParam( ':'.$column_name, $parameter_name ); $insert->bindParam( ':'.$field_name, $where_value ); - $insert->execute(); + return $insert->execute(); } /**