]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Post/QuestionOption.php
Editing/removing of attached pictures is now possible via web
[friendica.git] / src / Model / Post / QuestionOption.php
index d5e82d57ddfb28d98b61206e0600b92ea65022b8..c4d354e137becbd9f6a00d3ae91192ea9ef7ebd6 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
 
 namespace Friendica\Model\Post;
 
-use \BadMethodCallException;
-use Friendica\Database\Database;
+use BadMethodCallException;
 use Friendica\Database\DBA;
 use Friendica\Database\DBStructure;
+use Friendica\DI;
 
 class QuestionOption
 {
@@ -44,7 +44,7 @@ class QuestionOption
                        throw new BadMethodCallException('Empty URI_id');
                }
 
-               $fields = DBStructure::getFieldsForTable('post-question-option', $data);
+               $fields = DI::dbaDefinition()->truncateFieldsForTable('post-question-option', $data);
 
                // Remove the key fields
                unset($fields['uri-id']);
@@ -56,4 +56,18 @@ class QuestionOption
 
                return DBA::update('post-question-option', $fields, ['uri-id' => $uri_id, 'id' => $id], $insert_if_missing ? true : []);
        }
+
+       /**
+        * Retrieves the question options associated with the provided item ID.
+        *
+        * @param int $uri_id
+        * @return array
+        * @throws \Exception
+        */
+       public static function getByURIId(int $uri_id)
+       {
+               $condition = ['uri-id' => $uri_id];
+
+               return DBA::selectToArray('post-question-option', [], $condition, ['order' => ['id']]);
+       }
 }