Skip to content
Snippets Groups Projects
Select Git revision
  • 1dc3fb7ef7adc517e921a4c768bdda8cc918ad3f
  • master default protected
  • 8.0
  • 9.0
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • nt-tools
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • grubba/wip/sakura/8.0
  • v8.0.2004
  • v8.0.2002
  • v8.0.2000
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
  • v8.0.1982
  • v8.0.1980
  • v8.0.1978
  • v8.0.1976
  • v8.0.1974
  • v8.0.1972
  • v8.0.1970
41 results

Sql.pike

Blame
  • Sql.pike 19.79 KiB
    /*
     * $Id: Sql.pike,v 1.90 2008/01/09 14:26:07 mast Exp $
     *
     * Implements the generic parts of the SQL-interface
     *
     * Henrik Grubbström 1996-01-09
     */
    
    #pike __REAL_VERSION__
    
    //! Implements those functions that need not be present in all SQL-modules.
    
    #define ERROR(X ...)	predef::error(X)
    
    //! Object to use for the actual SQL-queries.
    object master_sql;
    
    //! Convert all field names in mappings to lower_case.
    //! Only relevant to databases which only implement big_query(),
    //! and use upper/mixed-case fieldnames (eg Oracle).
    //! @int
    //! @value 0
    //!   No (default)
    //! @value 1
    //!   Yes
    //! @endint
    int(0..1) case_convert;
    
    //! @decl string quote(string s)
    //! Quote a string @[s] so that it can safely be put in a query.
    //!
    //! All input that is used in SQL-querys should be quoted to prevent
    //! SQL injections.
    //! 
    //! Consider this harmfull code:
    //! @code
    //!   string my_input = "rob' OR name!='rob";
    //!   string my_query = "DELETE FROM tblUsers WHERE name='"+my_input+"'";
    //!   my_db->query(my_query);
    //! @endcode
    //! 
    //! This type of problems can be avoided by quoting @tt{my_input@}.
    //! @tt{my_input@} would then probably read something like 
    //! @i{rob\' OR name!=\'rob@} 
    //!
    //! Usually this is done - not by calling quote explicitly - but through
    //! using a @[sprintf] like syntax
    //! @code
    //!   string my_input = "rob' OR name!='rob";
    //!   my_db->query("DELETE FROM tblUsers WHERE name=%s",my_input);
    //! @endcode
    
    function(string:string) quote = .sql_util.quote;
    
    //! @decl string encode_time(int t, int|void is_utc)
    //! Converts a system time value to an appropriately formatted time
    //! spec for the database.
    //! @param t
    //!   Time to encode.
    //! @param is_utc
    //!   If nonzero then time is taken as a "full" unix time spec
    //!   (where the date part is ignored), otherwise it's converted as a
    //!   seconds-since-midnight value.
    
    function(int,void|int:string) encode_time;
    
    //! @decl int decode_time(string t, int|void want_utc)
    //! Converts a database time spec to a system time value.
    //! @param t
    //!   Time spec to decode.