]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Post/QuestionOption.php
Merge pull request #13227 from BirdboyBolu/develop
[friendica.git] / src / Model / Post / QuestionOption.php
index 9ca4ba3b69dc2225b59794ccc27b734d5b5e29fe..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
  *
@@ -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()->truncateFieldsForTable('post-question-option', $data);
 
                // Remove the key fields
                unset($fields['uri-id']);
@@ -55,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']]);
+       }
 }