Branch: Tag:

1998-07-15

1998-07-15 16:04:55 by Johan Schön <js@opera.com>

Made the module a MODULE_PROVIDER. Use id->conf->call_provider("sql","sql_object",id) to get an SQL object.

Rev: server/modules/tags/sqltag.pike:1.24

1:   /* -  * $Id: sqltag.pike,v 1.23 1998/03/08 13:48:57 per Exp $ +  * $Id: sqltag.pike,v 1.24 1998/07/15 16:04:55 js Exp $    *    * A module for Roxen Challenger, which gives the tags    * <SQLQUERY> and <SQLOUTPUT>.
7:    * Henrik Grubbström 1997-01-12    */    - constant cvs_version="$Id: sqltag.pike,v 1.23 1998/03/08 13:48:57 per Exp $"; + constant cvs_version="$Id: sqltag.pike,v 1.24 1998/07/15 16:04:55 js Exp $";   constant thread_safe=1;   #include <module.h>   
26:      array register_module()   { -  return( ({ MODULE_PARSER, +  return( ({ MODULE_PARSER|MODULE_PROVIDER,    "SQL-module",    "This module gives the three tags &lt;SQLQUERY&gt;, "    "&lt;SQLOUTPUT&gt;, and &lt;SQLTABLE&gt;.<br>\n"
398:      #endif /* 0 */    +    /*    * Hook in the tags    */
418:   }      /* +  * Callback functions +  */ +  +  + object(sql) sql_object(object request_id) + { +  string host = query("hostname"); +  object(sql) con; +  function sql_connect = request_id->conf->sql_connect; +  mixed error; +  error = catch(con = sql_connect(host)); +  if(error) +  return 0; +  return con; + } +  + string query_provides() + { +  return "sql"; + } +  + /*    * Setting the defaults    */   
456:    if (_conf) {    conf = _conf;    } + //add_api_function("sql_query", api_sql_query, ({ "string", 0,"int" }));   }      void stop()