mirror of
https://github.com/friendica/friendica
synced 2025-01-03 16:02:19 +00:00
Fix errors in Database namespace
This commit is contained in:
parent
496f0755b1
commit
1fe730f514
11 changed files with 34 additions and 46 deletions
|
@ -233,7 +233,7 @@ class DBA
|
||||||
/**
|
/**
|
||||||
* Returns the number of columns of a statement
|
* Returns the number of columns of a statement
|
||||||
*
|
*
|
||||||
* @param object Statement object
|
* @param object $stmt Statement object
|
||||||
* @return int Number of columns
|
* @return int Number of columns
|
||||||
*/
|
*/
|
||||||
public static function columnCount($stmt): int
|
public static function columnCount($stmt): int
|
||||||
|
@ -243,7 +243,7 @@ class DBA
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows of a statement
|
* 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
|
* @return int Number of rows
|
||||||
*/
|
*/
|
||||||
public static function numRows($stmt): int
|
public static function numRows($stmt): int
|
||||||
|
@ -364,9 +364,9 @@ class DBA
|
||||||
* @return boolean was the delete successful?
|
* @return boolean was the delete successful?
|
||||||
* @throws \Exception
|
* @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
|
* 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
|
public static function errorNo(): int
|
||||||
{
|
{
|
||||||
|
|
|
@ -552,8 +552,10 @@ class Database
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var $stmt mysqli_stmt|PDOStatement */
|
/** @var mysqli_stmt|PDOStatement $stmt */
|
||||||
if (!$stmt = $this->connection->prepare($sql)) {
|
$stmt = $this->connection->prepare($sql);
|
||||||
|
|
||||||
|
if (!$stmt) {
|
||||||
$errorInfo = $this->connection->errorInfo();
|
$errorInfo = $this->connection->errorInfo();
|
||||||
$this->error = (string)$errorInfo[2];
|
$this->error = (string)$errorInfo[2];
|
||||||
$this->errorno = (int)$errorInfo[1];
|
$this->errorno = (int)$errorInfo[1];
|
||||||
|
@ -889,7 +891,7 @@ class Database
|
||||||
/**
|
/**
|
||||||
* Returns the number of columns of a statement
|
* Returns the number of columns of a statement
|
||||||
*
|
*
|
||||||
* @param object Statement object
|
* @param object $stmt Statement object
|
||||||
*
|
*
|
||||||
* @return int Number of columns
|
* @return int Number of columns
|
||||||
*/
|
*/
|
||||||
|
@ -910,7 +912,7 @@ class Database
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows of a statement
|
* 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
|
* @return int Number of rows
|
||||||
*/
|
*/
|
||||||
|
@ -1652,7 +1654,7 @@ class Database
|
||||||
/**
|
/**
|
||||||
* Returns the error number of the last query
|
* 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
|
public function errorNo(): int
|
||||||
{
|
{
|
||||||
|
|
|
@ -299,7 +299,7 @@ class Attach
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @see \Friendica\Database\DBA::delete
|
* @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
|
// get items to delete data info
|
||||||
$items = self::selectToArray(['backend-class', 'backend-ref'], $conditions);
|
$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)
|
public static function setPermissionFromBody(array $post)
|
||||||
|
|
|
@ -496,7 +496,7 @@ class Photo
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @see \Friendica\Database\DBA::delete
|
* @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
|
// get photo to delete data info
|
||||||
$photos = DBA::select('photo', ['id', 'backend-class', 'backend-ref'], $conditions);
|
$photos = DBA::select('photo', ['id', 'backend-class', 'backend-ref'], $conditions);
|
||||||
|
@ -516,7 +516,7 @@ class Photo
|
||||||
|
|
||||||
DBA::close($photos);
|
DBA::close($photos);
|
||||||
|
|
||||||
return DBA::delete('photo', $conditions, $options);
|
return DBA::delete('photo', $conditions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -774,8 +774,8 @@ class Post
|
||||||
* @return boolean was the delete successful?
|
* @return boolean was the delete successful?
|
||||||
* @throws \Exception
|
* @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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,16 +69,13 @@ class Content
|
||||||
* Delete a row from the post-content table
|
* Delete a row from the post-content table
|
||||||
*
|
*
|
||||||
* @param array $conditions Field condition(s)
|
* @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?
|
* @return boolean was the delete successful?
|
||||||
* @throws \Exception
|
* @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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -65,15 +65,12 @@ class Origin
|
||||||
* Delete a row from the post-origin table
|
* Delete a row from the post-origin table
|
||||||
*
|
*
|
||||||
* @param array $conditions Field condition(s)
|
* @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?
|
* @return boolean was the delete successful?
|
||||||
* @throws \Exception
|
* @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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,15 +68,12 @@ class Thread
|
||||||
* Delete a row from the post-thread table
|
* Delete a row from the post-thread table
|
||||||
*
|
*
|
||||||
* @param array $conditions Field condition(s)
|
* @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?
|
* @return boolean was the delete successful?
|
||||||
* @throws \Exception
|
* @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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,9 +79,9 @@ class ThreadUser
|
||||||
* @return boolean was the delete successful?
|
* @return boolean was the delete successful?
|
||||||
* @throws \Exception
|
* @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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -109,15 +109,12 @@ class User
|
||||||
* Delete a row from the post-user table
|
* Delete a row from the post-user table
|
||||||
*
|
*
|
||||||
* @param array $conditions Field condition(s)
|
* @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?
|
* @return boolean was the delete successful?
|
||||||
* @throws \Exception
|
* @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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,15 +95,13 @@ class UserNotification
|
||||||
* Delete a row from the post-user-notification table
|
* Delete a row from the post-user-notification table
|
||||||
*
|
*
|
||||||
* @param array $conditions Field condition(s)
|
* @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?
|
* @return boolean was the deletion successful?
|
||||||
* @throws Exception
|
* @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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue