Fix errors in Database namespace

This commit is contained in:
Art4 2024-12-03 20:36:29 +00:00
parent 496f0755b1
commit 1fe730f514
11 changed files with 34 additions and 46 deletions

View file

@ -233,7 +233,7 @@ class DBA
/**
* Returns the number of columns of a statement
*
* @param object Statement object
* @param object $stmt Statement object
* @return int Number of columns
*/
public static function columnCount($stmt): int
@ -243,7 +243,7 @@ class DBA
/**
* Returns the number of rows of a statement
*
* @param PDOStatement|mysqli_result|mysqli_stmt Statement object
* @param PDOStatement|mysqli_result|mysqli_stmt $stmt Statement object
* @return int Number of rows
*/
public static function numRows($stmt): int
@ -364,9 +364,9 @@ class DBA
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(string $table, array $conditions, array $options = []): bool
public static function delete(string $table, array $conditions): bool
{
return DI::dba()->delete($table, $conditions, $options);
return DI::dba()->delete($table, $conditions);
}
/**
@ -756,7 +756,7 @@ class DBA
/**
* Returns the error number of the last query
*
* @return string Error number (0 if no error)
* @return int Error number (0 if no error)
*/
public static function errorNo(): int
{

View file

@ -552,8 +552,10 @@ class Database
break;
}
/** @var $stmt mysqli_stmt|PDOStatement */
if (!$stmt = $this->connection->prepare($sql)) {
/** @var mysqli_stmt|PDOStatement $stmt */
$stmt = $this->connection->prepare($sql);
if (!$stmt) {
$errorInfo = $this->connection->errorInfo();
$this->error = (string)$errorInfo[2];
$this->errorno = (int)$errorInfo[1];
@ -889,7 +891,7 @@ class Database
/**
* Returns the number of columns of a statement
*
* @param object Statement object
* @param object $stmt Statement object
*
* @return int Number of columns
*/
@ -910,7 +912,7 @@ class Database
/**
* Returns the number of rows of a statement
*
* @param PDOStatement|mysqli_result|mysqli_stmt Statement object
* @param PDOStatement|mysqli_result|mysqli_stmt $stmt Statement object
*
* @return int Number of rows
*/
@ -1652,7 +1654,7 @@ class Database
/**
* Returns the error number of the last query
*
* @return string Error number (0 if no error)
* @return int Error number (0 if no error)
*/
public function errorNo(): int
{

View file

@ -299,7 +299,7 @@ class Attach
* @throws \Exception
* @see \Friendica\Database\DBA::delete
*/
public static function delete(array $conditions, array $options = []): bool
public static function delete(array $conditions): bool
{
// get items to delete data info
$items = self::selectToArray(['backend-class', 'backend-ref'], $conditions);
@ -315,7 +315,7 @@ class Attach
}
}
return DBA::delete('attach', $conditions, $options);
return DBA::delete('attach', $conditions);
}
public static function setPermissionFromBody(array $post)

View file

@ -496,7 +496,7 @@ class Photo
* @throws \Exception
* @see \Friendica\Database\DBA::delete
*/
public static function delete(array $conditions, array $options = []): bool
public static function delete(array $conditions): bool
{
// get photo to delete data info
$photos = DBA::select('photo', ['id', 'backend-class', 'backend-ref'], $conditions);
@ -516,7 +516,7 @@ class Photo
DBA::close($photos);
return DBA::delete('photo', $conditions, $options);
return DBA::delete('photo', $conditions);
}
/**

View file

@ -774,8 +774,8 @@ class Post
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(array $conditions, array $options = []): bool
public static function delete(array $conditions): bool
{
return DBA::delete('post', $conditions, $options);
return DBA::delete('post', $conditions);
}
}

View file

@ -69,16 +69,13 @@ class Content
* Delete a row from the post-content table
*
* @param array $conditions Field condition(s)
* @param array $options
* - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
*
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(array $conditions, array $options = [])
public static function delete(array $conditions)
{
return DBA::delete('post-content', $conditions, $options);
return DBA::delete('post-content', $conditions);
}

View file

@ -65,15 +65,12 @@ class Origin
* Delete a row from the post-origin table
*
* @param array $conditions Field condition(s)
* @param array $options
* - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
*
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(array $conditions, array $options = [])
public static function delete(array $conditions)
{
return DBA::delete('post-origin', $conditions, $options);
return DBA::delete('post-origin', $conditions);
}
}

View file

@ -68,15 +68,12 @@ class Thread
* Delete a row from the post-thread table
*
* @param array $conditions Field condition(s)
* @param array $options
* - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
*
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(array $conditions, array $options = [])
public static function delete(array $conditions)
{
return DBA::delete('post-thread', $conditions, $options);
return DBA::delete('post-thread', $conditions);
}
}

View file

@ -79,9 +79,9 @@ class ThreadUser
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(array $conditions, array $options = [])
public static function delete(array $conditions)
{
return DBA::delete('post-thread-user', $conditions, $options);
return DBA::delete('post-thread-user', $conditions);
}
/**

View file

@ -109,15 +109,12 @@ class User
* Delete a row from the post-user table
*
* @param array $conditions Field condition(s)
* @param array $options
* - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
*
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(array $conditions, array $options = [])
public static function delete(array $conditions)
{
return DBA::delete('post-user', $conditions, $options);
return DBA::delete('post-user', $conditions);
}
}

View file

@ -95,15 +95,13 @@ class UserNotification
* Delete a row from the post-user-notification table
*
* @param array $conditions Field condition(s)
* @param array $options - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
*
* @return boolean was the deletion successful?
* @throws Exception
*/
public static function delete(array $conditions, array $options = []): bool
public static function delete(array $conditions): bool
{
return DBA::delete('post-user-notification', $conditions, $options);
return DBA::delete('post-user-notification', $conditions);
}
/**