Entities/Administrators/Model/AdministratorsEntityMapper.php
public function create(string $name, string $username, string $passwordClear, array $roleIds, bool $active): int
    {
        // insert administrator then administrator_roles in a transaction
        pg_query("BEGIN");

        try {
            $administratorId = $this->administratorsTableMapper->callInsert($name, $username, $passwordClear, $active);
        } catch (\Exception $e) {
            pg_query("ROLLBACK");
            throw $e;
        }

        try {
            $this->insertAdministratorRoles((int) $administratorId, $roleIds);
        } catch (\Exception $e) {
            pg_query("ROLLBACK");
            throw $e;
        }

        pg_query("COMMIT");
        return $administratorId;
    }
public function create(string $name, string $username, string $passwordClear, array $roleIds, bool $active): int
    {
        // insert administrator then administrator_roles in a transaction
        pg_query("BEGIN");

        try {
            $administratorId = $this->administratorsTableMapper->callInsert($name, $username, $passwordClear, $active);
        } catch (\Exception $e) {
            pg_query("ROLLBACK");
            throw $e;
        }

        try {
            $this->insertAdministratorRoles((int) $administratorId, $roleIds);
        } catch (\Exception $e) {
            pg_query("ROLLBACK");
            throw $e;
        }

        pg_query("COMMIT");
        return $administratorId;
    }
public function create ( string $ name , string $ username , string $ passwordClear , array $ roleIds , bool $ active ) : int { // insert administrator then administrator_roles in a transaction pg_query ( "BEGIN" ) ; try { $ administratorId = $ this -> administratorsTableMapper -> callInsert ( $ name , $ username , $ passwordClear , $ active ) ; } catch ( \ Exception $ e ) { pg_query ( "ROLLBACK" ) ; throw $ e ; } try { $ this -> insertAdministratorRoles ( ( int ) $ administratorId , $ roleIds ) ; } catch ( \ Exception $ e ) { pg_query ( "ROLLBACK" ) ; throw $ e ; } pg_query ( "COMMIT" ) ; return $ administratorId ; }
any validation should be done prior
any validation should be done prior