http request from mydbr

(7 posts) (3 voices)

Tags:

No tags yet.

  1. maron, Member

    Hi.

    I have a stored procedure which updates a table in mysql database that is cached in my application - the procedure runs every minute.

    I can refresh the cache by calling an url, is there anyway I could call that url directly from mydbr (select 'dbr.httprequest','url goes here';

    I do not need the results of the url necessarily, I only need to call the url to tell my application when it needs to flush the cache.

    Is this already possible or is it something we could implement?

    Regards, Maron

    Posted 2 years ago #
  2. myDBR Team, Key Master

    Is there an action in myDBR which should trigger the URL call or do you just want myDBR to regularily call an URL from your application?

    --
    myDBR Team

    Posted 2 years ago #
  3. maron, Member

    In this case, I only need to call the url if certain conditions in the stored procedure are met. There are many ways around this, but the easiest would be something like this

    if ( @changed > 0 ) THEN
    select 'dbr.httprequest','GET','<urlthatflushescache>';

    END IF;

    Posted 2 years ago #
  4. myDBR Team, Key Master

    If client side call is enough, you can use dbr.javascript:

    select 'dbr.javascript', '$.get( "https://yoururl/...." );';

    If you need to use server side call, use a myDBR extension.

    --
    myDBR Team

    Posted 2 years ago #
  5. biceda, Member

    I have a similar request. Once an import is complete, I'd like to redirect to another URL.

    I have set the dbr.import.finish to call a stored procedure and in the finished stored procedure i have tried a few things.
    (sample finish stored procedure)

    DROP PROCEDURE IF EXISTS sp_DBR_Process_Scan_Data
    $$
    CREATE PROCEDURE `sp_DBR_Process_Scan_Data`()
    BEGIN

    select concat('dbr.html:Import done<script>$("#loading").html("Update complete...Redirecting");</script>');

    select 'dbr.url', 'https://mydomaingoeshere.com/admin/myHouseKeeping.php';

    END
    $$

    The result displays the code, does not redirect (see below screen output)

    Import Scan Data

    Summary
    Total rows Errors
    45 0
    Finish
    Import done
    dbr.url https://mydomaingoeshere.com/admin/myHouseKeeping.php

    Posted 2 years ago #
  6. myDBR Team, Key Master

    The import finish proc is not parsed as full report, hence the myDBR commands were not effective. However, we see the benefit of a redirect after the import has been done, so we added a quick support for dbr.javascript for the import finish proc. If you run the myDBR updater, you can now use following syntax for your redirect (in the example the redirect will happen after 3 seconds):

    create procedure sp_DBR_import_end()
    begin select 'Redirecting...';
    select 'dbr.javascript', 'window.setTimeout( function(){window.location = "https://mydomaingoeshere.com/admin/myHouseKeeping.php"; }, 3000 );'; end

    --
    myDBR Team

    Posted 2 years ago #
  7. biceda, Member

    Works perfectly..

    Thanks again.

    Posted 2 years ago #

Reply

You must log in to post.