"dba" is now "DBA". This hadn't been respected at some places (#5655)
* "dba" is now "DBA". This hadn't been respected at some places * Cleaning up unneeded stuff
This commit is contained in:
parent
d29cb1acaf
commit
dc3d2d5988
5 changed files with 17 additions and 28 deletions
|
@ -5,9 +5,9 @@ use Friendica\Database\DBA;
|
||||||
/**
|
/**
|
||||||
* @brief execute SQL query with printf style args - deprecated
|
* @brief execute SQL query with printf style args - deprecated
|
||||||
*
|
*
|
||||||
* Please use the dba:: functions instead:
|
* Please use the DBA:: functions instead:
|
||||||
* dba::select, dba::exists, dba::insert
|
* DBA::select, DBA::exists, DBA::insert
|
||||||
* dba::delete, dba::update, dba::p, dba::e
|
* DBA::delete, DBA::update, DBA::p, DBA::e
|
||||||
*
|
*
|
||||||
* @param $args Query parameters (1 to N parameters of different types)
|
* @param $args Query parameters (1 to N parameters of different types)
|
||||||
* @return array|bool Query array
|
* @return array|bool Query array
|
||||||
|
|
|
@ -65,7 +65,7 @@ class System extends BaseObject
|
||||||
while ($func = array_pop($trace)) {
|
while ($func = array_pop($trace)) {
|
||||||
if (!empty($func['class'])) {
|
if (!empty($func['class'])) {
|
||||||
// Don't show multiple calls from the "dba" class to show the essential parts of the callstack
|
// Don't show multiple calls from the "dba" class to show the essential parts of the callstack
|
||||||
if ((($previous['class'] != $func['class']) || ($func['class'] != 'dba')) && ($previous['function'] != 'q')) {
|
if ((($previous['class'] != $func['class']) || ($func['class'] != 'Friendica\Database\DBA')) && ($previous['function'] != 'q')) {
|
||||||
$classparts = explode("\\", $func['class']);
|
$classparts = explode("\\", $func['class']);
|
||||||
$callstack[] = array_pop($classparts).'::'.$func['function'];
|
$callstack[] = array_pop($classparts).'::'.$func['function'];
|
||||||
$previous = $func;
|
$previous = $func;
|
||||||
|
|
|
@ -372,7 +372,7 @@ class DBA
|
||||||
* @usage Example: $r = p("SELECT * FROM `item` WHERE `guid` = ?", $guid);
|
* @usage Example: $r = p("SELECT * FROM `item` WHERE `guid` = ?", $guid);
|
||||||
*
|
*
|
||||||
* Please only use it with complicated queries.
|
* Please only use it with complicated queries.
|
||||||
* For all regular queries please use dba::select or dba::exists
|
* For all regular queries please use DBA::select or DBA::exists
|
||||||
*
|
*
|
||||||
* @param string $sql SQL statement
|
* @param string $sql SQL statement
|
||||||
* @return bool|object statement object or result object
|
* @return bool|object statement object or result object
|
||||||
|
@ -590,7 +590,7 @@ class DBA
|
||||||
/**
|
/**
|
||||||
* @brief Executes a prepared statement like UPDATE or INSERT that doesn't return data
|
* @brief Executes a prepared statement like UPDATE or INSERT that doesn't return data
|
||||||
*
|
*
|
||||||
* Please use dba::delete, dba::insert, dba::update, ... instead
|
* Please use DBA::delete, DBA::insert, DBA::update, ... instead
|
||||||
*
|
*
|
||||||
* @param string $sql SQL statement
|
* @param string $sql SQL statement
|
||||||
* @return boolean Was the query successfull? False is returned only if an error occurred
|
* @return boolean Was the query successfull? False is returned only if an error occurred
|
||||||
|
@ -685,7 +685,7 @@ class DBA
|
||||||
/**
|
/**
|
||||||
* Fetches the first row
|
* Fetches the first row
|
||||||
*
|
*
|
||||||
* Please use dba::selectFirst or dba::exists whenever this is possible.
|
* Please use DBA::selectFirst or DBA::exists whenever this is possible.
|
||||||
*
|
*
|
||||||
* @brief Fetches the first row
|
* @brief Fetches the first row
|
||||||
* @param string $sql SQL statement
|
* @param string $sql SQL statement
|
||||||
|
@ -1303,7 +1303,7 @@ class DBA
|
||||||
*
|
*
|
||||||
* $params = array("order" => array("id", "received" => true), "limit" => 10);
|
* $params = array("order" => array("id", "received" => true), "limit" => 10);
|
||||||
*
|
*
|
||||||
* $data = dba::select($table, $fields, $condition, $params);
|
* $data = DBA::select($table, $fields, $condition, $params);
|
||||||
*/
|
*/
|
||||||
public static function select($table, array $fields = [], array $condition = [], array $params = [])
|
public static function select($table, array $fields = [], array $condition = [], array $params = [])
|
||||||
{
|
{
|
||||||
|
@ -1345,7 +1345,7 @@ class DBA
|
||||||
* or:
|
* or:
|
||||||
* $condition = ["`uid` = ? AND `network` IN (?, ?)", 1, 'dfrn', 'dspr'];
|
* $condition = ["`uid` = ? AND `network` IN (?, ?)", 1, 'dfrn', 'dspr'];
|
||||||
*
|
*
|
||||||
* $count = dba::count($table, $condition);
|
* $count = DBA::count($table, $condition);
|
||||||
*/
|
*/
|
||||||
public static function count($table, array $condition = [])
|
public static function count($table, array $condition = [])
|
||||||
{
|
{
|
||||||
|
@ -1399,7 +1399,7 @@ class DBA
|
||||||
/* Workaround for MySQL Bug #64791.
|
/* Workaround for MySQL Bug #64791.
|
||||||
* Never mix data types inside any IN() condition.
|
* Never mix data types inside any IN() condition.
|
||||||
* In case of mixed types, cast all as string.
|
* In case of mixed types, cast all as string.
|
||||||
* Logic needs to be consistent with dba::p() data types.
|
* Logic needs to be consistent with DBA::p() data types.
|
||||||
*/
|
*/
|
||||||
$is_int = false;
|
$is_int = false;
|
||||||
$is_alpha = false;
|
$is_alpha = false;
|
||||||
|
@ -1530,7 +1530,7 @@ class DBA
|
||||||
case 'mysqli':
|
case 'mysqli':
|
||||||
// MySQLi offers both a mysqli_stmt and a mysqli_result class.
|
// MySQLi offers both a mysqli_stmt and a mysqli_result class.
|
||||||
// We should be careful not to assume the object type of $stmt
|
// We should be careful not to assume the object type of $stmt
|
||||||
// because dba::p() has been able to return both types.
|
// because DBA::p() has been able to return both types.
|
||||||
if ($stmt instanceof mysqli_stmt) {
|
if ($stmt instanceof mysqli_stmt) {
|
||||||
$stmt->free_result();
|
$stmt->free_result();
|
||||||
$ret = $stmt->close();
|
$ret = $stmt->close();
|
||||||
|
|
|
@ -273,36 +273,25 @@ class Group extends BaseObject
|
||||||
*
|
*
|
||||||
* @param array $group_ids
|
* @param array $group_ids
|
||||||
* @param boolean $check_dead
|
* @param boolean $check_dead
|
||||||
* @param boolean $use_gcontact
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function expand($group_ids, $check_dead = false, $use_gcontact = false)
|
public static function expand($group_ids, $check_dead = false)
|
||||||
{
|
{
|
||||||
if (!is_array($group_ids) || !count($group_ids)) {
|
if (!is_array($group_ids) || !count($group_ids)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = '`gid` IN (' . substr(str_repeat("?, ", count($group_ids)), 0, -2) . ')';
|
$stmt = DBA::select('group_member', ['contact-id'], ['gid' => $group_ids]);
|
||||||
if ($use_gcontact) {
|
|
||||||
$sql = 'SELECT `gcontact`.`id` AS `contact-id` FROM `group_member`
|
|
||||||
INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
|
|
||||||
INNER JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl`
|
|
||||||
WHERE ' . $condition;
|
|
||||||
$param_arr = array_merge([$sql], $group_ids);
|
|
||||||
$stmt = call_user_func_array('dba::p', $param_arr);
|
|
||||||
} else {
|
|
||||||
$condition_array = array_merge([$condition], $group_ids);
|
|
||||||
$stmt = DBA::select('group_member', ['contact-id'], $condition_array);
|
|
||||||
}
|
|
||||||
|
|
||||||
$return = [];
|
$return = [];
|
||||||
while($group_member = DBA::fetch($stmt)) {
|
while($group_member = DBA::fetch($stmt)) {
|
||||||
$return[] = $group_member['contact-id'];
|
$return[] = $group_member['contact-id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($check_dead && !$use_gcontact) {
|
if ($check_dead) {
|
||||||
Contact::pruneUnavailable($return);
|
Contact::pruneUnavailable($return);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1050,7 +1050,7 @@ class Diaspora
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contact = dba::selectFirst('contact', [], ['id' => $cid]);
|
$contact = DBA::selectFirst('contact', [], ['id' => $cid]);
|
||||||
if (!DBA::isResult($contact)) {
|
if (!DBA::isResult($contact)) {
|
||||||
// This here shouldn't happen at all
|
// This here shouldn't happen at all
|
||||||
logger("Haven't found a contact for user " . $uid . " and handle " . $handle, LOGGER_DEBUG);
|
logger("Haven't found a contact for user " . $uid . " and handle " . $handle, LOGGER_DEBUG);
|
||||||
|
@ -1079,7 +1079,7 @@ class Diaspora
|
||||||
// It is deactivated by now, due to side effects. See issue https://github.com/friendica/friendica/pull/4033
|
// It is deactivated by now, due to side effects. See issue https://github.com/friendica/friendica/pull/4033
|
||||||
// It is not removed by now. Possibly the code is needed?
|
// It is not removed by now. Possibly the code is needed?
|
||||||
//if (!$is_comment && $contact["rel"] == Contact::FOLLOWER && in_array($importer["page-flags"], array(Contact::PAGE_FREELOVE))) {
|
//if (!$is_comment && $contact["rel"] == Contact::FOLLOWER && in_array($importer["page-flags"], array(Contact::PAGE_FREELOVE))) {
|
||||||
// dba::update(
|
// DBA::update(
|
||||||
// 'contact',
|
// 'contact',
|
||||||
// array('rel' => Contact::FRIEND, 'writable' => true),
|
// array('rel' => Contact::FRIEND, 'writable' => true),
|
||||||
// array('id' => $contact["id"], 'uid' => $contact["uid"])
|
// array('id' => $contact["id"], 'uid' => $contact["uid"])
|
||||||
|
|
Loading…
Reference in a new issue