Roxen.git / server / modules / tags / sqltag.pike

version» Context lines:

Roxen.git/server/modules/tags/sqltag.pike: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>.    *    * 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>      /* Compatibility with old versions of the sqltag module. */   // #define SQL_TAG_COMPAT      inherit "module";   inherit "roxenlib";      import Array;   import Sql;      /*    * Module interface functions    */      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"    "Usage:<ul>\n"    "<table border=0>\n"    "<tr><td valign=top><b>&lt;sqloutput&gt;</b></td>"    "<td>Executes an SQL-query, and "    "replaces #-quoted fieldnames with the results. # is "    "quoted as ##. The content inbetween &lt;sqloutput&gt; and "    "&lt;/sqloutput&gt; is repeated once for every row in the "
Roxen.git/server/modules/tags/sqltag.pike:391: Inside #if 0
     string dumpid_tag(string tag_name, mapping args,    object request_id, mapping defines)   {    return(sprintf("<pre>ID:%O\n</pre>\n",    mkmapping(indices(request_id), values(request_id))));   }      #endif /* 0 */    +    /*    * Hook in the tags    */      mapping query_tag_callers()   {    return( ([ "sql":sqlquery_tag, "sqlquery":sqlquery_tag,    "sqltable":sqltable_tag,   #if 0    "dumpid":dumpid_tag   #endif /* 0 */    ]) );   }      mapping query_container_callers()   {    return( ([ "sqloutput":sqloutput_tag, "sqlelse":sqlelse_tag ]) );   }      /* -  +  * 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    */      void create()   {    defvar("hostname", "localhost", "Default SQL-database host",    TYPE_STRING, "Specifies the default host to use for SQL-queries.\n"    "This argument can also be used to specify which SQL-server to "    "use by specifying an \"SQL-URL\":<ul>\n"    "<pre>[<i>sqlserver</i>://][[<i>user</i>][:<i>password</i>]@]"
Roxen.git/server/modules/tags/sqltag.pike:449:    * More interface functions    */      object conf;      void start(int level, object _conf)   {    if (_conf) {    conf = _conf;    } + //add_api_function("sql_query", api_sql_query, ({ "string", 0,"int" }));   }      void stop()   {   }      string status()   {    if (catch {    object o;