Please enable JavaScript to view this site.

The manual for the JobRouter developer

Navigation: SDK > Interfaces

ConnectionManagerInterface

Scroll Prev Top Next More

Methods

 

Method

Parameters

Parameter description

Return

Description

getJobDB

-

-

JobDBInterface

Returns the default JobRouter database connection

getDBConnection

$connectionName: string

Connection name

JobDBInterface

Returns a JobRouter database connection by its name

Example

 

<?php

 

use Doctrine\DBAL\Exception;

use JobRouter\Common\Database\ResultInterface;

use JobRouter\Sdk\ConnectionManagerInterface;

 

return function (ConnectionManagerInterface $connectionManager): void {

    echo '<h1 style="color: #fc0">SDK database example!</h1>';

 

    echo '<h3 style="color: #fc0;">JobRouter Users (internal connection) - getJobDB()</h3>';

    try {

        $jobDB = $connectionManager->getJobDB();

        // Do something with the $jobDB

    } catch (\JobRouterException|Exception $e) {

        echo '<h3 style="color: #f44;">ERROR!</h3>';

        echo '<p style="color: #f44;">Message: ' . $e->getMessage() .  '</p>';

    }

 

    echo '<h3 style="color: #59aa6e;">JobRouter (Global connection) - getDBConnection(\'GC_JOBDATA\')</h3>';

    try {

        $gcJobData = $connectionManager->getDBConnection('GC_JOBDATA');

        // Do something with the $gcJobData

    } catch (\JobRouterException|Exception $e) {

        echo '<h3 style="color: #f44;">ERROR!</h3>';

        echo '<p style="color: #f44;">Message: ' . $e->getMessage() .  '</p>';

    }

 

    echo '<h3 style="color: #59aa6e;">JobRouter (Global connection) - getDBConnection(\'GlobalConnectionDoesNotExists\')</h3>';

    try {

        $connectionManager->getDBConnection('GlobalConnectionDoesNotExists');

    } catch (\JobRouterException|\Exception $e) {

        echo '<h3 style="color: #f44;">ERROR!</h3>';

        echo '<p style="color: #f44;">Message: ' . $e->getMessage() .  '</p>';

    }

};