Connecting Tech Pros Worldwide Help | Site Map

Saving XML to db

simon
Guest
 
Posts: n/a
#1: Jul 17 '05
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


Alvaro G. Vicario
Guest
 
Posts: n/a
#2: Jul 17 '05

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
--
simon
Guest
 
Posts: n/a
#3: Jul 17 '05

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


Daniel Tryba
Guest
 
Posts: n/a
#4: Jul 17 '05

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.

Michael Hare
Guest
 
Posts: n/a
#5: Jul 17 '05

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