LTI Integration Library 4.10.3
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
DataConnector_pdo_oci.php
1<?php
2
4
13{
14
20 private static $sequence = array();
21
28 public function __construct($db, $dbTableNamePrefix = '')
29 {
30 parent::__construct($db, $dbTableNamePrefix);
31 $this->dateFormat = 'd-M-Y';
32 $db->setAttribute(\PDO::ATTR_STRINGIFY_FETCHES, true);
33 if (empty(self::$sequence)) {
34 $n = strlen($this->dbTableNamePrefix) + 6;
35 $sql = 'SELECT TABLE_NAME, DATA_DEFAULT FROM USER_TAB_COLUMNS ' .
36 "WHERE (TABLE_NAME LIKE UPPER('{$this->dbTableNamePrefix}lti2_%')) AND (COLUMN_NAME = UPPER(CONCAT(SUBSTR(TABLE_NAME, {$n}), '_pk')))";
37 $query = $this->db->prepare($sql);
38 if ($this->executeQuery($sql, $query)) {
39 $row = $query->fetchAll(\PDO::FETCH_ASSOC);
40 foreach ($row as $entry) {
41 self::$sequence[substr($entry['TABLE_NAME'], strlen($this->dbTableNamePrefix))] = str_replace('nextval',
42 'currval', $entry['DATA_DEFAULT']);
43 }
44 }
45 }
46 }
47
48###
49### PROTECTED METHODS
50###
51
59 protected function getLastInsertId($tableName)
60 {
61 $pk = 0;
62 $sql = 'SELECT ' . self::$sequence[strtoupper($tableName)] . ' FROM dual';
63 $query = $this->db->prepare($sql);
64 if ($this->executeQuery($sql, $query)) {
65 $row = $query->fetch(\PDO::FETCH_ASSOC);
66 $pk = intval(array_values($row)[0]);
67 }
68 return $pk;
69 }
70
71}
Class to represent an LTI Data Connector for PDO variations for Oracle connections.
getLastInsertId($tableName)
Get the ID for the last record inserted into a table.
__construct($db, $dbTableNamePrefix='')
Class constructor.
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.
$dbTableNamePrefix
Prefix for database table names.