php run function returned by mssql query

Posted on 2012-09-21
Last Modified: 2012-09-21
i am working on a way to do callback function in my code.  i have a webpage that adds or changes records in my database, some of these changes require other changes to happen after, some dont, and some require something else to happen.

the database is to track training for employees, i have a table of training for employees and as well as a table of all the different training we do.  i would like to be able to store a php function in the second table in a nvarchar(max) so that each training can have its own callback.  when the php changes/adds training, it would query the second table to see if it has a callback, pull it down and execute it.

the problem i am having is that i dont know how to execute this function after i pull it down.  it would be stored in a php string variable and im not sure how to execute it.  i have read about eval() function but i dont like using it.  i was wondering if there is a way of doing this.
Question by:talonsblade
    LVL 107

    Accepted Solution

    I would not do it exactly this way.  Instead, I would store the name of a function or class method that should be run when certain callbacks are required.  You can invoke the callback with include().  Your PHP scripts will stay in the file system where they belong and your data base can list the names of the callbacks in a succinct and easy-to-maintain way.

    Author Comment

    i had thought of doing it this way and after reading more this will probably be the way to go.
    LVL 107

    Expert Comment

    by:Ray Paseur
    LVL 107

    Expert Comment

    by:Ray Paseur
    Thanks for the points; I think you're on firm ground with the more "decoupled" design. ~Ray

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
    Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now