LTI Integration Library  3.1.0
PHP class library for building LTI integrations
DataConnector_pdo_oci.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use ceLTIc\LTI;
13 
23 {
29  private static $sequence = array();
30 
37  public function __construct($db, $dbTableNamePrefix = '')
38  {
39  parent::__construct($db, $dbTableNamePrefix);
40  $this->dateFormat = 'd-M-Y';
41  $db->setAttribute(\PDO::ATTR_STRINGIFY_FETCHES, true);
42  if (empty(self::$sequence)) {
43  $n = strlen($this->dbTableNamePrefix) + 6;
44  $sql = 'SELECT TABLE_NAME, DATA_DEFAULT FROM USER_TAB_COLUMNS ' .
45  "WHERE (TABLE_NAME LIKE UPPER('{$this->dbTableNamePrefix}lti2_%')) AND (COLUMN_NAME = UPPER(CONCAT(SUBSTR(TABLE_NAME, {$n}), '_pk')))";
46  $query = $this->db->prepare($sql);
47  if ($query->execute()) {
48  $row = $query->fetchAll(\PDO::FETCH_ASSOC);
49  foreach ($row as $entry) {
50  self::$sequence[substr($entry['TABLE_NAME'], strlen($this->dbTableNamePrefix))] = str_replace('nextval',
51  'currval', $entry['DATA_DEFAULT']);
52  }
53  }
54  }
55  }
56 
57 ###
58 ### PROTECTED METHODS
59 ###
60 
61  protected function getLastInsertId($tableName)
62  {
63  $pk = 0;
64  $sql = 'SELECT ' . self::$sequence[strtoupper($tableName)] . ' FROM dual';
65  $query = $this->db->prepare($sql);
66  if ($query->execute()) {
67  $row = $query->fetch(\PDO::FETCH_ASSOC);
68  $pk = intval(array_values($row)[0]);
69  }
70  return $pk;
71  }
72 
73 }
$dbTableNamePrefix
Prefix for database table names.
Class to represent a tool consumer.
Class to represent a tool consumer context.
Definition: Context.php:17
Class to represent an LTI Data Connector for PDO connections.
__construct($db, $dbTableNamePrefix='')
Class constructor.
Class to represent a tool consumer nonce.
Class to represent a tool consumer resource link share.
Class to represent a tool consumer user.
Definition: UserResult.php:15
Class to represent a tool consumer resource link share key.
Class to represent an LTI Data Connector for PDO variations for Oracle connections.