Saving XML to db

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • simon

    Saving XML to db

    Hi All,

    What would be the best way to save XML to a database?

    I mean I can use the example
    'http://www.php.net/manual/en/function.mysql-real-escape-string.php'.

    they give a function to prevent any SQL Injection,

    function quote_smart($va lue)
    {
    // Stripslashes
    if (get_magic_quot es_gpc()) {
    $value = stripslashes($v alue);
    }
    // Quote if not integer
    if (!is_numeric($v alue)) {
    $value = "'" . mysql_real_esca pe_string($valu e) . "'";
    }
    return $value;
    }

    but then how do I get the data back, (as intended), from the db?
    what would be the reverse of the above code?

    Many thanks
    Simon


  • Alvaro G. Vicario

    #2
    Re: Saving XML to db

    *** simon escribió/wrote (Fri, 11 Feb 2005 18:15:00 -0000):[color=blue]
    > but then how do I get the data back, (as intended), from the db?
    > what would be the reverse of the above code?[/color]

    No.

    --
    -+ Álvaro G. Vicario - Burgos, Spain
    +- http://www.demogracia.com (la web de humor barnizada para la intemperie)
    ++ Manda tus dudas al grupo, no a mi buzón
    -+ Send your questions to the group, not to my mailbox
    --

    Comment

    • simon

      #3
      Re: Saving XML to db

      "Alvaro G. Vicario" <kAlvaroNOSPAMT HANKS@terra.es> wrote in message
      news:njkvfc6lba pn$.14a8buxv6vu ud.dlg@40tude.n et...[color=blue]
      > *** simon escribió/wrote (Fri, 11 Feb 2005 18:15:00 -0000):[color=green]
      >> but then how do I get the data back, (as intended), from the db?
      >> what would be the reverse of the above code?[/color]
      >
      > No.
      >[/color]

      Sorry, what does that mean? is there no way to get the data back as
      intended? So how would I save XML then?

      Simon


      Comment

      • Daniel Tryba

        #4
        Re: Saving XML to db

        simon <spambucket@myo ddweb.com> wrote:[color=blue][color=green][color=darkred]
        >>> but then how do I get the data back, (as intended), from the db?
        >>> what would be the reverse of the above code?[/color]
        >>
        >> No.
        >>[/color]
        >
        > Sorry, what does that mean? is there no way to get the data back as
        > intended?[/color]

        The code tries to handle magic quotes settings (which IMHO is extremely
        evil by default), so if $value isn't extracted from GET/POST/COOKIE it
        will be wrongfully stripped.

        Comment

        • Michael Hare

          #5
          Re: Saving XML to db

          I would use a Native XML data base like Apache.org's Xindice (http://xml.apache.org/xindice/) or DBXML (http://www.dbxml.com/)

          The advantage is the DOM of the XML is stored not the textual strings, so you can search the XML data in the database using XML
          constructs like XPATH (very cool).

          I think both os these run in either the Jetty Java servlet container or under Tomcat.

          I've heard, but not confirmed, that Oracle 8 and above can also provide an XML schema capable of the same functions.



          On Fri, 11 Feb 2005 18:15:00 -0000, "simon" <spambucket@myo ddweb.com> wrote:
          [color=blue]
          >Hi All,
          >
          >What would be the best way to save XML to a database?
          >
          >I mean I can use the example
          >'http://www.php.net/manual/en/function.mysql-real-escape-string.php'.
          >
          >they give a function to prevent any SQL Injection,
          >
          >function quote_smart($va lue)
          >{
          > // Stripslashes
          > if (get_magic_quot es_gpc()) {
          > $value = stripslashes($v alue);
          > }
          > // Quote if not integer
          > if (!is_numeric($v alue)) {
          > $value = "'" . mysql_real_esca pe_string($valu e) . "'";
          > }
          > return $value;
          >}
          >
          >but then how do I get the data back, (as intended), from the db?
          >what would be the reverse of the above code?
          >
          >Many thanks
          >Simon
          >[/color]

          Comment

          Working...