LTI Integration Library 4.10.3
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
DataConnector_pdo_pgsql.php
1<?php
2
4
5use ceLTIc\LTI;
8
17{
18###
19### ResourceLink methods
20###
21
34 public function getUserResultSourcedIDsResourceLink($resourceLink, $localOnly, $idScope)
35 {
36 $id = $resourceLink->getRecordId();
37 $userResults = array();
38
39 if ($localOnly) {
40 $sql = 'SELECT u.user_result_pk, u.lti_result_sourcedid, u.lti_user_id, u.created, u.updated ' .
41 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME . ' AS u ' .
42 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME . ' AS rl ' .
43 'ON u.resource_link_pk = rl.resource_link_pk ' .
44 'WHERE (rl.resource_link_pk = :id) AND (rl.primary_resource_link_pk IS NULL)';
45 $query = $this->db->prepare($sql);
46 $query->bindValue('id', $id, \PDO::PARAM_INT);
47 } else {
48 $sql = 'SELECT u.user_result_pk, u.lti_result_sourcedid, u.lti_user_id, u.created, u.updated ' .
49 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME . ' AS u ' .
50 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME . ' AS rl ' .
51 'ON u.resource_link_pk = rl.resource_link_pk ' .
52 'WHERE ((rl.resource_link_pk = :id) AND (rl.primary_resource_link_pk IS NULL)) OR ' .
53 '((rl.primary_resource_link_pk = :pid) AND share_approved)';
54 $query = $this->db->prepare($sql);
55 $query->bindValue('id', $id, \PDO::PARAM_INT);
56 $query->bindValue('pid', $id, \PDO::PARAM_INT);
57 }
58 if ($this->executeQuery($sql, $query)) {
59 while ($row = $query->fetch(\PDO::FETCH_ASSOC)) {
60 $row = array_change_key_case($row);
61 $userresult = LTI\UserResult::fromRecordId($row['user_result_pk'], $resourceLink->getDataConnector());
62 $userresult->setRecordId(intval($row['user_result_pk']));
63 $userresult->ltiResultSourcedId = $row['lti_result_sourcedid'];
64 $userresult->created = strtotime($row['created']);
65 $userresult->updated = strtotime($row['updated']);
66 if (is_null($idScope)) {
67 $userResults[] = $userresult;
68 } else {
69 $userResults[$userresult->getId($idScope)] = $userresult;
70 }
71 }
72 }
73
74 return $userResults;
75 }
76
77###
78### ResourceLinkShareKey methods
79###
80
88 public function saveResourceLinkShareKey($shareKey)
89 {
90 $id = $shareKey->getId();
91 $expires = date("{$this->dateFormat} {$this->timeFormat}", $shareKey->expires);
92 $sql = "INSERT INTO {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' ' .
93 '(share_key_id, resource_link_pk, auto_approve, expires) ' .
94 'VALUES (:id, :prlid, :approve, :expires)';
95 $query = $this->db->prepare($sql);
96 $query->bindValue('id', $id, \PDO::PARAM_STR);
97 $query->bindValue('prlid', $shareKey->resourceLinkId, \PDO::PARAM_INT);
98 $query->bindValue('approve', $shareKey->autoApprove, \PDO::PARAM_INT);
99 $query->bindValue('expires', $expires, \PDO::PARAM_STR);
100 $ok = $this->executeQuery($sql, $query);
101
102 return $ok;
103 }
104
105}
Class to represent an LTI Data Connector for PDO variations for PostgreSQL connections.
saveResourceLinkShareKey($shareKey)
Save resource link share key object.
getUserResultSourcedIDsResourceLink($resourceLink, $localOnly, $idScope)
Get array of user objects.
Class to represent an LTI Data Connector for PDO connections.
executeQuery($sql, $query, $reportError=true)
Execute a database query.
Class to provide a connection to a persistent store for LTI objects.
Class to represent a platform resource link share key.