Connecting Tech Pros Worldwide Help | Site Map

Saving XML to db

  #1  
Old July 17th, 2005, 12:27 PM
simon
Guest
 
Posts: n/a
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($value)
{
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not integer
if (!is_numeric($value)) {
$value = "'" . mysql_real_escape_string($value) . "'";
}
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


  #2  
Old July 17th, 2005, 12:27 PM
Alvaro G. Vicario
Guest
 
Posts: n/a

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
--
  #3  
Old July 17th, 2005, 12:27 PM
simon
Guest
 
Posts: n/a

re: Saving XML to db


"Alvaro G. Vicario" <kAlvaroNOSPAMTHANKS@terra.es> wrote in message
news:njkvfc6lbapn$.14a8buxv6vuud.dlg@40tude.net...[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


  #4  
Old July 17th, 2005, 12:27 PM
Daniel Tryba
Guest
 
Posts: n/a

re: Saving XML to db


simon <spambucket@myoddweb.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.

  #5  
Old July 17th, 2005, 01:55 PM
Michael Hare
Guest
 
Posts: n/a

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@myoddweb.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($value)
>{
> // Stripslashes
> if (get_magic_quotes_gpc()) {
> $value = stripslashes($value);
> }
> // Quote if not integer
> if (!is_numeric($value)) {
> $value = "'" . mysql_real_escape_string($value) . "'";
> }
> 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]

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Complex Associative Array to XML FIle and Back swayze answers 1 March 7th, 2006 10:25 PM
OO DB question Chris answers 8 December 28th, 2005 07:15 PM
Efficient non-db storage? Mike O. answers 6 November 22nd, 2005 06:29 AM
Efficient non-db storage? Mike O. answers 6 July 21st, 2005 11:35 AM