<?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 Question
{
throw new BadMethodCallException('Empty URI_id');
}
- $fields = DBStructure::getFieldsForTable('post-question', $data);
+ $fields = DI::dbaDefinition()->truncateFieldsForTable('post-question', $data);
// Remove the key fields
unset($fields['uri-id']);
return DBA::update('post-question', $fields, ['uri-id' => $uri_id], $insert_if_missing ? true : []);
}
+
+ /**
+ * @param integer $id Question ID
+ * @param array $fields Array of selected fields, empty for all
+ * @return array|boolean Question record if it exists, false otherwise
+ */
+ public static function getById($id, $fields = [])
+ {
+ return DBA::selectFirst('post-question', $fields, ['id' => $id]);
+ }
}