You are here: Re: MySQL -> XML -> MySQL « PHP SQL « IT news, forums, messages
Re: MySQL -> XML -> MySQL

Posted by Captain Paralytic on 10/19/06 12:33

strawberry wrote:
> I'm trying to go back and forth between a db and XML pages that filter
> db data.
> I have a multidimensional array (parsed from XML) like this
> (simplified):
blah, blah, blah snipped
> So now I'd like to walk through the array and build MySQL statements of
> the type:
>
> "INSERT INTO TABLE1 (ID,PARENT,FIELD1,FIELD2,etc.) VALUES
> (ID1,Parent,Value1,Value2,etc.)"
>
> or
>
> "UPDATE TABLE1 SET (PARENT,FIELD1,FIELD2,etc.) =
> (Parent,Value1,Value2,etc) WHERE ID = ID1"
>
> depending on whether or not the ID exists.

Use INSERT ... ON DUPLICATE KEY UPDATE to solve this in one hit (or
possibly REPLACE INTO)

> Using array_walk_recursive() I can successfully traverse the array, but
> I'm still struggling to build the appropriate queries.
> Also, I haven't thought through what happens when items originally
> selected from the database are subsequently deleted from the XML prior
> to constructing the array.

Instead of completely deleting from the XML, can you either:

1) leave the ID in and delete everything else
or
2) leave the ID in and add a DELETE instruction

In either case, examining the node should give you the hint required to
create a DELETE FROM query instead of one of the other ones.

Regards
Paul

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация