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.
This commit is contained in:
@@ -151,10 +151,11 @@ abstract class Db implements IDb
|
|||||||
* @param bool $wherevalue
|
* @param bool $wherevalue
|
||||||
* @param bool $rowfield
|
* @param bool $rowfield
|
||||||
* @param bool $rowvalue
|
* @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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -166,19 +166,20 @@ final class pdo extends Mysql implements IPdo
|
|||||||
* @param string $parameter_name
|
* @param string $parameter_name
|
||||||
* @param string $field_name
|
* @param string $field_name
|
||||||
* @param string $where_value
|
* @param string $where_value
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function updateColumnByFieldWhere( $tablename = self::PLACE_TABLE_NAME,
|
public static function updateColumnByFieldWhere( $tablename = self::PLACE_TABLE_NAME,
|
||||||
$column_name = IMysql::PLACE_COLUMN_NAME,
|
$column_name = IMysql::PLACE_COLUMN_NAME,
|
||||||
$parameter_name = IMysql::PLACE_SEARCH_TERM,
|
$parameter_name = IMysql::PLACE_SEARCH_TERM,
|
||||||
$field_name = IMysql::PLACE_FIELD_NAME,
|
$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();
|
$statement = parent::getInstance( self::getSettingsSection() )->getConn();
|
||||||
$query = "UPDATE " . $tablename . " SET " . $column_name . " = :" . $column_name . " WHERE " . $field_name . " = :". $field_name;
|
$query = "UPDATE " . $tablename . " SET " . $column_name . " = :" . $column_name . " WHERE " . $field_name . " = :". $field_name;
|
||||||
$insert = $statement->prepare($query);
|
$insert = $statement->prepare($query);
|
||||||
$insert->bindParam( ':'.$column_name, $parameter_name );
|
$insert->bindParam( ':'.$column_name, $parameter_name );
|
||||||
$insert->bindParam( ':'.$field_name, $where_value );
|
$insert->bindParam( ':'.$field_name, $where_value );
|
||||||
$insert->execute();
|
return $insert->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user