Split DBStructure & View to avoid DB-calls and dependencies for basic operations
- new "Definition" classes vor DB and Views - new "Writer" classes to create SQL definitions for DB and Views - DBStructure & View are responsible to execute DB-querys
This commit is contained in:
@@ -26,6 +26,7 @@ use Friendica\Core\Protocol;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Post;
|
||||
|
||||
class Content
|
||||
@@ -44,7 +45,7 @@ class Content
|
||||
throw new BadMethodCallException('Empty URI_id');
|
||||
}
|
||||
|
||||
$fields = DBStructure::getFieldsForTable('post-content', $data);
|
||||
$fields = DI::dbaDefinition()->getFieldsForTable('post-content', $data);
|
||||
|
||||
// Additionally assign the key fields
|
||||
$fields['uri-id'] = $uri_id;
|
||||
@@ -67,7 +68,7 @@ class Content
|
||||
throw new BadMethodCallException('Empty URI_id');
|
||||
}
|
||||
|
||||
$fields = DBStructure::getFieldsForTable('post-content', $data);
|
||||
$fields = DI::dbaDefinition()->getFieldsForTable('post-content', $data);
|
||||
|
||||
// Remove the key fields
|
||||
unset($fields['uri-id']);
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Friendica\Model\Post;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Post;
|
||||
|
||||
class History
|
||||
@@ -37,7 +37,7 @@ class History
|
||||
*/
|
||||
public static function add(int $uri_id, array $item)
|
||||
{
|
||||
$allfields = DBStructure::definition('', false);
|
||||
$allfields = DI::dbaDefinition()->getAll();
|
||||
$fields = array_keys($allfields['post-history']['fields']);
|
||||
|
||||
$post = Post::selectFirstPost($fields, ['uri-id' => $uri_id]);
|
||||
@@ -52,7 +52,7 @@ class History
|
||||
}
|
||||
|
||||
$update = false;
|
||||
$changed = DBStructure::getFieldsForTable('post-history', $item);
|
||||
$changed = DI::dbaDefinition()->getFieldsForTable('post-history', $item);
|
||||
unset($changed['uri-id']);
|
||||
unset($changed['edited']);
|
||||
foreach ($changed as $field => $content) {
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Friendica\Model\Post;
|
||||
use BadMethodCallException;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\DI;
|
||||
|
||||
class Question
|
||||
{
|
||||
@@ -42,7 +43,7 @@ class Question
|
||||
throw new BadMethodCallException('Empty URI_id');
|
||||
}
|
||||
|
||||
$fields = DBStructure::getFieldsForTable('post-question', $data);
|
||||
$fields = DI::dbaDefinition()->getFieldsForTable('post-question', $data);
|
||||
|
||||
// Remove the key fields
|
||||
unset($fields['uri-id']);
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Friendica\Model\Post;
|
||||
use BadMethodCallException;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\DI;
|
||||
|
||||
class QuestionOption
|
||||
{
|
||||
@@ -43,7 +44,7 @@ class QuestionOption
|
||||
throw new BadMethodCallException('Empty URI_id');
|
||||
}
|
||||
|
||||
$fields = DBStructure::getFieldsForTable('post-question-option', $data);
|
||||
$fields = DI::dbaDefinition()->getFieldsForTable('post-question-option', $data);
|
||||
|
||||
// Remove the key fields
|
||||
unset($fields['uri-id']);
|
||||
|
||||
@@ -25,6 +25,7 @@ use \BadMethodCallException;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\DI;
|
||||
|
||||
class Thread
|
||||
{
|
||||
@@ -42,7 +43,7 @@ class Thread
|
||||
throw new BadMethodCallException('Empty URI_id');
|
||||
}
|
||||
|
||||
$fields = DBStructure::getFieldsForTable('post-thread', $data);
|
||||
$fields = DI::dbaDefinition()->getFieldsForTable('post-thread', $data);
|
||||
|
||||
// Additionally assign the key fields
|
||||
$fields['uri-id'] = $uri_id;
|
||||
@@ -65,7 +66,7 @@ class Thread
|
||||
throw new BadMethodCallException('Empty URI_id');
|
||||
}
|
||||
|
||||
$fields = DBStructure::getFieldsForTable('post-thread', $data);
|
||||
$fields = DI::dbaDefinition()->getFieldsForTable('post-thread', $data);
|
||||
|
||||
// Remove the key fields
|
||||
unset($fields['uri-id']);
|
||||
|
||||
@@ -25,6 +25,7 @@ use \BadMethodCallException;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\DI;
|
||||
|
||||
class ThreadUser
|
||||
{
|
||||
@@ -43,7 +44,7 @@ class ThreadUser
|
||||
throw new BadMethodCallException('Empty URI_id');
|
||||
}
|
||||
|
||||
$fields = DBStructure::getFieldsForTable('post-thread-user', $data);
|
||||
$fields = DI::dbaDefinition()->getFieldsForTable('post-thread-user', $data);
|
||||
|
||||
// Additionally assign the key fields
|
||||
$fields['uri-id'] = $uri_id;
|
||||
@@ -68,7 +69,7 @@ class ThreadUser
|
||||
throw new BadMethodCallException('Empty URI_id');
|
||||
}
|
||||
|
||||
$fields = DBStructure::getFieldsForTable('post-thread-user', $data);
|
||||
$fields = DI::dbaDefinition()->getFieldsForTable('post-thread-user', $data);
|
||||
|
||||
// Remove the key fields
|
||||
unset($fields['uri-id']);
|
||||
|
||||
@@ -25,6 +25,7 @@ use Friendica\Database\DBA;
|
||||
use \BadMethodCallException;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\DI;
|
||||
|
||||
class User
|
||||
{
|
||||
@@ -47,7 +48,7 @@ class User
|
||||
return false;
|
||||
}
|
||||
|
||||
$fields = DBStructure::getFieldsForTable('post-user', $data);
|
||||
$fields = DI::dbaDefinition()->getFieldsForTable('post-user', $data);
|
||||
|
||||
// Additionally assign the key fields
|
||||
$fields['uri-id'] = $uri_id;
|
||||
@@ -81,7 +82,7 @@ class User
|
||||
throw new BadMethodCallException('Empty URI_id');
|
||||
}
|
||||
|
||||
$fields = DBStructure::getFieldsForTable('post-user', $data);
|
||||
$fields = DI::dbaDefinition()->getFieldsForTable('post-user', $data);
|
||||
|
||||
// Remove the key fields
|
||||
unset($fields['uri-id']);
|
||||
|
||||
@@ -67,7 +67,7 @@ class UserNotification
|
||||
throw new BadMethodCallException('Empty URI_id');
|
||||
}
|
||||
|
||||
$fields = DBStructure::getFieldsForTable('post-user-notification', $data);
|
||||
$fields = DI::dbaDefinition()->getFieldsForTable('post-user-notification', $data);
|
||||
|
||||
$fields['uri-id'] = $uri_id;
|
||||
$fields['uid'] = $uid;
|
||||
@@ -91,7 +91,7 @@ class UserNotification
|
||||
throw new BadMethodCallException('Empty URI_id');
|
||||
}
|
||||
|
||||
$fields = DBStructure::getFieldsForTable('post-user-notification', $data);
|
||||
$fields = DI::dbaDefinition()->getFieldsForTable('post-user-notification', $data);
|
||||
|
||||
// Remove the key fields
|
||||
unset($fields['uri-id']);
|
||||
|
||||
Reference in New Issue
Block a user