Roxen.git
/
server
/
base_server
/
module.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/base_server/module.pike:1:
// This file is part of Roxen WebServer. // Copyright © 1996 - 2001, Roxen IS.
-
// $Id: module.pike,v 1.
124
2001/08/
14
15
:
11
:
26
per
Exp $
+
// $Id: module.pike,v 1.
125
2001/08/
23
18
:
05
:
05
nilsson
Exp $
#include <module_constants.h> #include <module.h> #include <request_trace.h> constant __pragma_save_parent__ = 1; inherit "basic_defvar"; mapping(string:array(int)) error_log=([]);
Roxen.git/server/base_server/module.pike:170:
{ return (this_object()->register_module()[2]); } string sname( ) { return my_configuration()->otomod[ this_object() ]; } ModuleInfo my_moduleinfo( )
-
//! Returns the associated
@ref{ModuleInfo}
object
+
//! Returns the associated
@[ModuleInfo]
object
{ string f = sname(); if( f ) return roxen.find_module( (f/"#")[0] ); } void save_me() { my_configuration()->save_one( this_object() ); my_configuration()->module_changed( my_moduleinfo(), this_object() ); }
Roxen.git/server/base_server/module.pike:444:
//! Returns the name of a table in the 'shared' database that is //! unique for this module. It is possible to select another database //! by using @[set_my_db] before calling this function. //! //! You can use @[create_sql_tables] instead of this function if you want //! to create more than one table in one go. //! //! In the first form, @[name] is the (postfix of) the name of the //! table, and @[types] is an array of defenitions, as an example: //!
-
//!
@example{
+
//!
@code{
//! cache_table = get_my_table( "cache", ({ //! "id INT UNSIGNED AUTO_INCREMENT", //! "data BLOB", //! }) );
-
//!
@}
+
//! @}
//! //! In the second form, the whole table defenition is instead sent as //! a string. The cases where the name is not included (the third and //! fourth form) is equivalent to the first two cases with the name "" //! //! If the table does not exist in the datbase, it is created. //!
-
+
//! @note
+
//! This function may not be called from create
+
//
// If it exists, but it's defenition is different, the table will be // altered with a ALTER TABLE call to conform to the defenition. This // might not work if the database the table resides in is not a MySQL // database (normally it is, but it's possible, using @[set_my_db], // to change this).
-
//
-
//! @note This function may not be called from create
+
{ string oname; if( !defenition ) { defenition = name; oname = name = ""; } else if(strlen(name)) name = "_"+(oname = name);
Roxen.git/server/base_server/module.pike:522:
// if( error ) // { // if( strlen( name ) ) // name = " for "+name; // report_notice( "Failed to update table defenition"+name+": "+ // describe_error( error ) ); // } return __my_tables[ "&"+oname+";" ] = res; }
-
-
-
-
+
static string my_db = "shared";
-
+
static void set_my_db( string to ) //! Select the database in which tables will be created with //! get_my_table, and also the one that will be returned by //! @[get_my_sql] { my_db = to; } Sql.Sql get_my_sql( int|void read_only ) //! Return a SQL-object for the database set with @[set_my_db], //! defaulting to the 'shared' database. If read_only is specified, //! the database will be opened in read_only mode. //! //! See also @[DBManager.get] { return DBManager.cached_get( my_db, _my_configuration, read_only ); }