Manage the database IAM policy

Example:
```
$iam = $database->iam();
```

@return Iam
775844
public function iam()
    {
        if (!$this->iam) {
            $this->iam = new Iam(
                new IamDatabase($this->connection),
                $this->name
            );
        }

        return $this->iam;
    }
1098690
public function getDb()
    {
        if ($this->_db === NULL and $this->getConfig('main/db/engine')) {
            $this->_db = new Db();
        }

        return $this->_db;
    }
512874
public function createDatabaseDriver()
    {
        $provider = $this->createDatabaseProvider();
        return new Guard($provider, $this->app['session.store'], $this->name);
    }
1331912
private function _getDefaultDB()
    {
        // For ReadDatabase checking Master first
        if ($this->_db) {
            return $this->_db;
        }
        
        if (!isset($this->db)) {
            get_instance()->load->database();
        }
        // No need to set as reference because $this->db is refered to &DB already.
        return get_instance()->db;
    }
100962
public function createCommand($db = null)
    {
        if ($this->primaryModel !== null) {
            // lazy loading a relational query
            if ($this->via instanceof self) {
                // via pivot index
                $viaModels = $this->via->findJunctionRows([$this->primaryModel]);
                $this->filterByModels($viaModels);
            } elseif (is_array($this->via)) {
                // via relation
                /* @var $viaQuery ActiveQuery */
                list($viaName, $viaQuery) = $this->via;
                if ($viaQuery->multiple) {
                    $viaModels = $viaQuery->all();
                    $this->primaryModel->populateRelation($viaName, $viaModels);
                } else {
                    $model = $viaQuery->one();
                    $this->primaryModel->populateRelation($viaName, $model);
                    $viaModels = $model === null ? [] : [$model];
                }
                $this->filterByModels($viaModels);
            } else {
                $this->filterByModels([$this->primaryModel]);
            }
        }

        $this->setConnection($db);
        $db = $this->getConnection();

        if ($this->sql === null) {
            list ($sql, $params) = $db->getQueryBuilder()->build($this);
        } else {
            $sql = $this->sql;
            $params = $this->params;
        }

        return $db->createCommand($sql, $params);
    }
125925
public function getDatabase() : ?string 
    {
        if ( ! $this->hasDatabase()) {
            $this->setDatabase($this->getDefaultDatabase());
        }
        return $this->database;
    }
877826
public function select()
    {
        $this->db->setQuery('USE ' . $this->db->quoteName($this->name))->execute();

        return $this;
    }
475576
public static function &_getDbMaster ()
	{
		
		// Get the default master
		
		$obj	=& self::_getResource ('db-master');
		
		// Failing that try to get a random master
		
		if (!$obj)
		{
			
			$obj	=& self::_getRandomDbResource ('db-master');
			
			// Default to database resource if no valid master
		
			if (!$obj)
			{
				$obj =& self::_getResource ('db');
			}
			
		}
		
		// Return database connection
		
		return $obj;
		
	}
654692
public function normalizeDeclaration()
    {
        if (empty($this->getTable())) {
            $this->getConstants()->remove('TABLE');
        }

        if (empty($this->getDatabase())) {
            $this->getConstants()->remove('DATABASE');
        }

        return $this;
    }
242560
public function createDatabase(Database $database): self
    {
        if ($this->hasDatabase($database::getName())) {
            throw new InvalidArgumentException('Database '.$database::getName().' already added');
        }

        $this->databases[$database::getName()] = $database;

        return $this;
    }
111542
public static function db()
    {
        if (self::$db === null) {
            $rc = rcube::get_instance();
            $db = rcube_db::factory($rc->config->get('db_dsnw'));

            $db->set_debug((bool)$rc->config->get('sql_debug'));

            // Connect to database
            $db->db_connect('w');

            if (!$db->is_connected()) {
                rcube::raise_error("Error connecting to database: " . $db->is_error(), false, true);
            }

            self::$db = $db;
        }

        return self::$db;
    }
1029246
public function select()
    {
        $this->db->disconnect();

        $this->db->setDatabaseName($this->getName());

        return $this;
    }
1176185
public function &getDbMaster ()
	{
		
		// Get the default master
		
		$obj	=& $this->getResource ('db-master');
		
		// Failing that try to get a random master
		
		if (!$obj)
		{
			
			$obj	=& self::_getRandomDbResource ('db-master');
			
			// Default to database resource if no valid master
		
			if (!$obj)
			{
				$obj =& $this->getResource ('db');
			}
			
			// Set object master to use in the future

			$this->setResourceObj ('db-master', $obj);
			
		}
		
		// Return database connection
		
		return $obj;
		
	}
772104
public function setDatabase($database = [], $name = 'default')
    {
        $this->database = $database;
        $this->dbName   = $name;

        return $this;
    }
722578
public static function database()
    {
        $args = func_get_args();
        //
        switch ($args[0]) {
            case 'mysql': return self::mysql($args[1], $args[2], $args[3], $args[4], $args[5]); break;

            default:
                // code...
                break;
        }
    }
442379
public function setManagedBy($dn)
    {
        if ($dn instanceof Model) {
            $dn = $dn->getDn();
        }

        return $this->setFirstAttribute($this->schema->managedBy(), $dn);
    }
698610
public function database()
    {
        if (!$this->_step('license')) {
            $this->redirect(['plugin' => 'Installer', 'controller' => 'startup', 'action' => 'license']);
        }

        if (!empty($this->request->data)) {
            $dbInstaller = new DatabaseInstaller();
            if ($dbInstaller->install($this->request->data())) {
                $this->_step();
                $this->redirect(['plugin' => 'Installer', 'controller' => 'startup', 'action' => 'account']);
            } else {
                $errors = '';
                foreach ($dbInstaller->errors() as $error) {
                    $errors .= "\t<li>{$error}</li>\n";
                }
                $this->Flash->danger("<ul>\n{$errors}</ul>\n");
            }
        }

        $this->title(__d('installer', 'Database Configuration'));
    }