[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

php run function returned by mssql query

Posted on 2012-09-21
4
Medium Priority
?
441 Views
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.
0
Comment
Question by:talonsblade
  • 3
4 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 38421777
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.
0
 

Author Comment

by:talonsblade
ID: 38421791
i had thought of doing it this way and after reading more this will probably be the way to go.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 38421848
0
 
LVL 111

Expert Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses
Course of the Month18 days, 19 hours left to enroll

834 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