What I want to do is create an object containing a function that takes a MySQL querystring as one argument and a refrence to a function as the other. Like so:
[pseudocode]
object mysql;
{
vars;
function open; //open dbconnection
function close; //guess
function query(querystring, function_ref);
{
result = mysql_query(querystring);
for each in result function_ref(result);
}
}
the point is that i whish the mysql->querry to not just be able to return the results but in fact be able to format and print the results directly. As the querys will probabl require diffrent formating depending of the database I'm querying, I have to come up with some way of sending a "koncept" with the query to get it as I want. A userlisting will probably require a diffrent formation than a newsdraft ...
function listusers
{
function print(result);
{
echo "<div class="user">result->name</div>";
}
mysql->open;
mysql->query("select * from users order by name", &print);
mysql->close;
}
Am I just way of or can it be done? It's a (I think) wonderful way to structure the code. Keeping the parts that are logically rellevant together and the common parts out ... But maybee it cant be done (havent found any examples of it anyway), or maybee theres a better way to do it ...
I dont know so now I'm asking you guys ... ;o)
tnx /d-Pixie, Sweden