LPC Library Functions: db_fetch

NAME

db_fetch() - return the results of a SQL query

SYNOPSIS

mixed *db_fetch( int db_handle, int row );

DESCRIPTION

db_fetch() returns the result set from the last database transaction performed through db_exec() on the handle 'db_handle' in question for the row 'row'. For example, db_exec(10, "SELECT player_name from t_player") might have returned two rows. Typical code to extract that data would be:

     string *res;
     mixed rows;
     int dbconn, i;

     dbconn = db_connect("nightmare.imaginary.com", "db_mud");
     if( dbconn < 1 ) return 0;
     rows = db_exec(dbconn, "SELECT player_name from t_player");
     if( !rows ) write("No rows returned.");
     else if( stringp(rows) ) write(rows); 
     for(i=1; i<=rows; i++) {
         res = db_fetch(dbconn, i);
         write(res[0]);
     }
     db_close(dbconn);
     return 1;
db_fetch() returns an array of columns from the named row on success.

Note that this efun is only available if the driver flag PACKAGE_DB is defined.

SEE ALSO

db_close(), db_commit(), db_connect(), db_exec(), db_rollback()
Page design by Frank Jacquette & Tim Hollebeek
Copyright (C) 1998 Tim Hollebeek & Frank Jacquette
Back to MudOS