use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\DI;
+use Friendica\Model\APContact;
+use Friendica\Model\Contact;
use Friendica\Protocol\ActivityPub;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
public static function countFollows(int $cid, array $condition = [])
{
$condition = DBA::mergeConditions($condition,
- ['`id` IN (
- SELECT `relation-cid`
- FROM `contact-relation`
- WHERE `cid` = ?
- AND `follows`
-)', $cid]
+ ['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)',
+ $cid]
);
return DI::dba()->count('contact', $condition);
public static function listFollows(int $cid, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
{
$condition = DBA::mergeConditions($condition,
- ['`id` IN (
- SELECT `relation-cid`
- FROM `contact-relation`
- WHERE `cid` = ?
- AND `follows`
-)', $cid]
+ ['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)',
+ $cid]
);
- $follows = DI::dba()->selectToArray(
- 'contact',
- $condition,
- [
- 'limit' => [$offset, $count],
- 'order' => [$shuffle ? 'RAND()' : 'name']
- ]
+ return DI::dba()->selectToArray('contact', [], $condition,
+ ['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
);
-
- return $follows;
}
/**
public static function countFollowers(int $cid, array $condition = [])
{
$condition = DBA::mergeConditions($condition,
- ['`id` IN (
- SELECT `cid`
- FROM `contact-relation`
- WHERE `relation-cid` = ?
- AND `follows`
-)', $cid]
+ ['`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)',
+ $cid]
);
return DI::dba()->count('contact', $condition);
public static function listFollowers(int $cid, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
{
$condition = DBA::mergeConditions($condition,
- ['`id` IN (
- SELECT `cid`
- FROM `contact-relation`
- WHERE `relation-cid` = ?
- AND `follows`
-)', $cid]
+ ['`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)', $cid]
);
- $followers = DI::dba()->selectToArray(
- 'contact',
- $condition,
- [
- 'limit' => [$offset, $count],
- 'order' => [$shuffle ? 'RAND()' : 'name']
- ]
+ $followers = DI::dba()->selectToArray('contact', [], $condition,
+ ['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
);
return $followers;
public static function countCommon(int $sourceId, int $targetId, array $condition = [])
{
$condition = DBA::mergeConditions($condition,
- ['`id` IN (
- SELECT `relation-cid`
- FROM `contact-relation`
- WHERE `cid` = ?
-)
- AND `id` IN (
- SELECT `relation-cid`
- FROM `contact-relation`
- WHERE `cid` = ?
-)', $sourceId, $targetId]
+ ['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ?)
+ AND `id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ?)',
+ $sourceId, $targetId]
);
$total = DI::dba()->count('contact', $condition);
public static function listCommon(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
{
$condition = DBA::mergeConditions($condition,
- ["`id` IN (
- SELECT `relation-cid`
- FROM `contact-relation`
- WHERE `cid` = ?
- AND `follows`
-)
- AND `id` IN (
- SELECT `relation-cid`
- FROM `contact-relation`
- WHERE `cid` = ?
- AND `follows`
-)", $sourceId, $targetId]
+ ["`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
+ AND `id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)",
+ $sourceId, $targetId]
);
- $contacts = DI::dba()->selectToArray(
- 'contact',
- $condition,
- [
- 'limit' => [$offset, $count],
- 'order' => [$shuffle ? 'name' : 'RAND()'],
- ]
+ $contacts = DI::dba()->selectToArray('contact', [], $condition,
+ ['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
);
return $contacts;
public static function countCommonFollows(int $sourceId, int $targetId, array $condition = [])
{
$condition = DBA::mergeConditions($condition,
- ['`id` IN (
- SELECT `relation-cid`
- FROM `contact-relation`
- WHERE `cid` = ?
- AND `follows`
-)
- AND `id` IN (
- SELECT `relation-cid`
- FROM `contact-relation`
- WHERE `cid` = ?
- AND `follows`
-)', $sourceId, $targetId]
+ ['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
+ AND `id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)',
+ $sourceId, $targetId]
);
$total = DI::dba()->count('contact', $condition);
public static function listCommonFollows(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
{
$condition = DBA::mergeConditions($condition,
- ["`id` IN (
- SELECT `relation-cid`
- FROM `contact-relation`
- WHERE `cid` = ?
- AND `follows`
-)
- AND `id` IN (
- SELECT `relation-cid`
- FROM `contact-relation`
- WHERE `cid` = ?
- AND `follows`
-)", $sourceId, $targetId]
+ ["`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
+ AND `id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)",
+ $sourceId, $targetId]
);
- $contacts = DI::dba()->selectToArray(
- 'contact',
- $condition,
- [
- 'limit' => [$offset, $count],
- 'order' => [$shuffle ? 'name' : 'RAND()'],
- ]
+ $contacts = DI::dba()->selectToArray('contact', [], $condition,
+ ['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
);
return $contacts;
public static function countCommonFollowers(int $sourceId, int $targetId, array $condition = [])
{
$condition = DBA::mergeConditions($condition,
- ['`id` IN (
- SELECT `cid`
- FROM `contact-relation`
- WHERE `relation-cid` = ?
- AND `follows`
-)
- AND `id` IN (
- SELECT `cid`
- FROM `contact-relation`
- WHERE `relation-cid` = ?
- AND `follows`
-)', $sourceId, $targetId]
+ ["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)
+ AND `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)",
+ $sourceId, $targetId]
);
- $total = DI::dba()->count('contact', $condition);
-
- return $total;
+ return DI::dba()->count('contact', $condition);
}
/**
public static function listCommonFollowers(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
{
$condition = DBA::mergeConditions($condition,
- ["`id` IN (
- SELECT `cid`
- FROM `contact-relation`
- WHERE `relation-cid` = ?
- AND `follows`
-)
- AND `id` IN (
- SELECT `cid`
- FROM `contact-relation`
- WHERE `relation-cid` = ?
- AND `follows`
-)", $sourceId, $targetId]
+ ["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)
+ AND `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)",
+ $sourceId, $targetId]
);
- $contacts = DI::dba()->selectToArray(
- 'contact',
- $condition,
- [
- 'limit' => [$offset, $count],
- 'order' => [$shuffle ? 'name' : 'RAND()'],
- ]
+ return DI::dba()->selectToArray('contact', [], $condition,
+ ['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
);
-
- return $contacts;
}
}