Grima 2018-08
Whispering into Alma's ear
Public Member Functions | List of all members
GrimaInstitution Class Reference

Interface to the GrimaDB database to retrieve API keys. More...

Inheritance diagram for GrimaInstitution:
GrimaDB

Public Member Functions

  addToDB ()
 
- Public Member Functions inherited from GrimaDB
  offsetExists ($offset)
 
  offsetGet ($offset)
 
  offsetSet ($offset, $value)
 
  offsetUnset ($offset)
 
  getIterator ()
 

Additional Inherited Members

- Static Public Member Functions inherited from GrimaDB
static  init ()
 
static  isEmpty ()
 
static  isStateless ()
 
static  getInstitutions ()
 
- Protected Member Functions inherited from GrimaDB
  getPasswordAlgorithm ()
 
- Static Protected Member Functions inherited from GrimaDB
static  getDb ()
 

Detailed Description

Interface to the GrimaDB database to retrieve API keys.

Definition at line 4776 of file grima-lib.php.

Member Function Documentation

◆ addToDB()

GrimaInstitution::addToDB ( )

Definition at line 4778 of file grima-lib.php.

4779 {
4780 $db = $this->getDb();
4781 if ($db === 'stateless') {
4782 throw new Exception("No database has been specified. Grima cannot add an institution until it knows where to add it.");
4783 }
4784 $query = $db->prepare('INSERT INTO institutions(institution,apikey,server) VALUES (:institution,:apikey,:server)');
4785 if (!$query) {
4786 $errorCode = $db->errorCode();
4787 $errorInfo = $db->errorInfo();
4788 throw new Exception(
4789 "Could not even prepare to insert into institution database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4790 );
4791 }
4792 $success = $query->execute(
4793 array(
4794 'institution' => $this['institution'],
4795 'apikey' => $this['apikey'],
4796 'server' => $this['server'],
4797 )
4798 );
4799 if (!$success) {
4800 $errorCode = $query->errorCode();
4801 $errorInfo = $query->errorInfo();
4802 throw new Exception(
4803 "Could not insert into user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4804 );
4805 }
4806 }
static getDb()
Definition: grima-lib.php:4695
static $db
Definition: grima-lib.php:4665

References GrimaDB\$db, and GrimaDB\getDb().


The documentation for this class was generated from the following file: