Connecting Tech Pros Worldwide Help | Site Map

Saving XML to db

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 11:27 AM
simon
Guest
 
Posts: n/a
Default 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($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, 11:27 AM
Alvaro G. Vicario
Guest
 
Posts: n/a
Default 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, 11:27 AM
simon
Guest
 
Posts: n/a
Default 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, 11:27 AM
Daniel Tryba
Guest
 
Posts: n/a
Default 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, 12:55 PM
Michael Hare
Guest
 
Posts: n/a
Default 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]

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.