Roxen.git / server / base_server / module.pike

version» Context lines:

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.162 2004/03/23 16:46:50 mast Exp $ + // $Id: module.pike,v 1.163 2004/03/23 17:15:16 mast 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:781:    name = "_"+name;       string res = hash(_my_configuration->name)->digits(36)    + "_" + replace(sname(),"#","_") + name;       return catch(get_my_sql()->query( "SELECT * FROM "+res+" LIMIT 1" ))?0:res;   }         static string|int get_my_table( string|array(string) name, -  void|array(string)|string defenition, +  void|array(string)|string definition,    string|void comment,    int|void flag )   //! @decl string get_my_table( string name, array(string) types ) - //! @decl string get_my_table( string name, string defenition ) - //! @decl string get_my_table( string defenition ) - //! @decl string get_my_table( array(string) defenition ) + //! @decl string get_my_table( string name, string definition ) + //! @decl string get_my_table( string definition ) + //! @decl string get_my_table( array(string) definition )   //!   //! 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.   //!   //! If @[flag] is true, return 1 if a table was created, and 0 otherwise.   //!
Roxen.git/server/base_server/module.pike:809:   //! table, and @[types] is an array of definitions, as an 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 + //! In the second form, the whole table definition 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 + // If it exists, but it's definition is different, the table will be + // altered with a ALTER TABLE call to conform to the definition. 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).   {    string oname;    int ddc; -  if( !defenition ) +  if( !definition )    { -  defenition = name; +  definition = name;    oname = name = "";    }    else if(strlen(name))    name = "_"+(oname = name);       Sql.Sql sql = get_my_sql();       string res = hash(_my_configuration->name)->digits(36)    + "_" + replace(sname(),"#","_") + name;       if( !sql )    {    report_error("Failed to get SQL handle, permission denied for "+my_db+"\n");    return 0;    } -  if( arrayp( defenition ) ) -  defenition *= ", "; +  if( arrayp( definition ) ) +  definition *= ", ";       if( catch(sql->query( "SELECT * FROM "+res+" LIMIT 1" )) )    {    ddc++;    mixed error =    catch    { -  get_my_sql()->query( "CREATE TABLE "+res+" ("+defenition+")" ); +  get_my_sql()->query( "CREATE TABLE "+res+" ("+definition+")" );    DBManager.is_module_table( this_object(), my_db, res,    oname+"\0"+comment );    };    if( error )    {    if( strlen( name ) )    name = " "+name;    report_error( "Failed to create table"+name+": "+    describe_error( error ) );    return 0;    }    if( flag )    {    __my_tables[ "&"+oname+";" ] = res;    return ddc;    }    return __my_tables[ "&"+oname+";" ] = res;    } - // // Update defenition if it has changed. + // // Update definition if it has changed.   // mixed error =   // catch   // { - // get_my_sql()->query( "ALTER TABLE "+res+" ("+defenition+")" ); + // get_my_sql()->query( "ALTER TABLE "+res+" ("+definition+")" );   // };   // if( error )   // {   // if( strlen( name ) )   // name = " for "+name; - // report_notice( "Failed to update table defenition"+name+": "+ + // report_notice( "Failed to update table definition"+name+": "+   // describe_error( error ) );   // }    if( flag )    {    __my_tables[ "&"+oname+";" ] = res;    return ddc;    }    return __my_tables[ "&"+oname+";" ] = res;   }