Page Blocks

Hosting sponsored by:

Point In Space

 

API: Log

Filename:
fwpLog_asyncSQL.ctag

Released With:
5.0.0

Current Version:
1.0.0

Status: Active

Min Lasso Tested: 8.1.0

Max Lasso Tested: 8.5.3

Related:

Still don't get it?

Check out the talk list archives, or join and ask your questions.

Documentation Error or Request?

Email documentation corrections or comments

API Reference

fwpLog_asyncAdd (Tag)

Description

This tag is designed to accept an array of pairs as well table definition information, and add a record to a data table with an asyncronous thread. This is generally for internal use by the log tags, but it can be used to support custom logs as well.

Syntax

fwpLog_asyncSQL:
   -logPairs = array of field pairs,
   -user = string,
   -pswd = string,
   -db = string,
   -tbl = string,
   -keyfld = string;

Examples

local:'logPairs' = (array:
   'logDate' = server_date: -extended,
   'logTime' = server_time,
   'logClientIP' = client_IP,
   'logAction' = #action, 
   'logUser' = #usrName, 
   'logUserID' = #usrRcrd, 
   'logTable' = #table, 
   'logRcrdNo' = #rcrd, 
   'logPageURL' = response_filePath);

fwpLog_asyncSQL:
   -logPairs = #logPairs,
   -user = $fw_gQueryUser,
   -pswd = $fw_gQueryPswd,
   -db = ($fw_tblLogData->find:'db'),
   -tbl = ($fw_tblLogData->find:'tbl'),
   -keyfld = ($fw_tblLogData->find:'keyfld');

Source Code

View in separate window

<?lassoscript
//............................................................................
//
//    pageblocks: (c) 2002-2007 http://www.pageblocks.org/
//
//............................................................................
/*

    {fileName=        fwpLog_asyncSQL.ctag }
    {rsrcType=        tag }
    {rsrcName=        fwpLog_asyncSQL }
    {rsrcHTTP=        www.pageblocks.org/refc/fwpLog_asyncSQL }

    {lassoVrsnMin=    8.1.0 }
    {lassoVrsnMax=    8.5.3 }

    {author=        Greg Willits }
    {authorEmail=    subscribe to pbTalk at www.pageblocks.org/talk/ }
    {authorHTTP=    www.pageblocks.org }

    {desc=            Launches an async write to a MySQL table. }

    {maintvsrn=        1.1 }
    {maintrelease=    5.2.0 }
    {maintdate=        2007-06-09 }
    {maintauthor=    Greg Willits }
    {maintnotes=    added log_critical }

    {maintvsrn=        1.0 }
    {maintrelease=    5.0.0 }
    {maintdate=        2006-01-16 }
    {maintauthor=    Greg Willits }
    {maintnotes=    initial release }

*/
//.............................................................................

define_tag:'fwpLog_asyncSQL', 
    -async,
    -required    = 'user',
    -required    = 'pswd',
    -required    = 'db',
    -required    = 'tbl',
    -required    = 'keyfld',
    -required    = 'logPairs';
    
    local('query'    = string);
    #query        = 'INSERT INTO ' + #db + '.' + #tbl + ' SET';
    iterate(#logPairs, local('i'));
        #query += (" " + #i->first + " = '" #i->second + "',");
    /iterate;
    #query->(removetrailing(','));
    inline:
        #logPairs,
        -username    = #user,
        -password    = #pswd,
        -database    = #db,
        -table        = #tbl,
        -keyfield    = #keyfld,
        -sql        = #query;
        
        if: error_code != 0;
            log_critical:('pbError : fwpLog_asyncSQL -- ' + error_currentError);
        /if;
        
    /inline;

/define_tag;
?>



© 2002-2013, pageblocks.org