19declare(strict_types=1);
58 $query =
'SELECT * FROM lti_consumer_results'
59 .
' WHERE id = ' .
$DIC->database()->quote($a_id,
'integer');
61 $res =
$DIC->database()->query($query);
62 if ($row =
$DIC->database()->fetchAssoc(
$res)) {
64 $resObj->fillData($row);
79 $logger =
$DIC->logger()->root();
80 $logger->info(
'getByKeys: ' . $a_obj_id .
' ' . $a_usr_id);
82 $query =
'SELECT * FROM lti_consumer_results'
83 .
' WHERE obj_id = ' .
$DIC->database()->quote($a_obj_id,
'integer')
84 .
' AND usr_id = ' .
$DIC->database()->quote($a_usr_id,
'integer');
86 $res =
$DIC->database()->query($query);
87 if ($row =
$DIC->database()->fetchAssoc(
$res)) {
89 $resObj->fillData($row);
91 } elseif ($a_create) {
93 $resObj->obj_id = $a_obj_id;
94 $resObj->usr_id = $a_usr_id;
95 $resObj->result =
null;
109 $this->
id = (
int) $data[
'id'];
110 $this->obj_id = (
int)
$data[
'obj_id'];
111 $this->usr_id = (
int)
$data[
'usr_id'];
112 $this->result =
$data[
'result'] ==
null ? null : (float)
$data[
'result'];
122 $logger =
$DIC->logger()->root();
124 $logger->info(
'save: ' . $this->obj_id .
' ' . $this->usr_id);
126 if (!isset($this->usr_id) || !isset($this->obj_id)) {
129 if (!isset($this->
id)) {
130 $this->
id = $DIC->database()->nextId(
'lti_consumer_results');
133 $logger =
$DIC->logger()->root();
135 $logger->info(
'save 2: ' . $this->obj_id .
' ' . $this->usr_id);
137 $DIC->database()->replace(
138 'lti_consumer_results',
140 'id' => array(
'integer', $this->
id)
143 'obj_id' => array(
'integer', $this->obj_id),
144 'usr_id' => array(
'integer', $this->usr_id),
145 'result' => array(
'float', $this->result)
179 $query =
'SELECT * FROM lti_consumer_results'
180 .
' WHERE obj_id = ' .
$DIC->database()->quote(
$objId,
'integer');
182 $res =
$DIC->database()->query($query);
186 if ($row =
$DIC->database()->fetchAssoc(
$res)) {
188 $resObj->fillData($row);
190 $results[$resObj->getUsrId()] = $resObj;
static getResultsForObject(int $objId)
static getByKeys(int $a_obj_id, int $a_usr_id, ?bool $a_create=false)
Get a result by object and user key.
save()
Save a result object.
fillData(array $data)
Fill the properties with data from an array.
static getById(int $a_id)
Get a result by id.