www.webdeveloper.com
Results 1 to 8 of 8

Thread: Does PHP + XML have any advantages over PHP + MySQL?

  1. #1
    Join Date
    Sep 2004
    Location
    At the corner of WALK and DONT WALK
    Posts
    1,714

    Does PHP + XML have any advantages over PHP + MySQL?

    The info is going to be added to, but not changed around a lot. And XML can be stored as a text file and directly uploaded, while with MySQL, it seems a bit more complicated to edit it--and keep a mirror site current with the main one.

  2. #2
    Join Date
    Aug 2006
    Posts
    1,917
    That depends largely on the scale of your project. If by "edit the database" you mean "get into a text editor and make changes", and "keep a mirror site current" you mean "periodically make a copy" then yes, those things seem pretty simple. But making changes to a database through an editor isn't usually how a large application will access a database, and implementing MySQL replication is likely much more robust than a periodic ftp of the file. And all this doesn't even touch the power of the SQL language over the tools available for manipulating XML.

    That said, I do have a site I've implemented with many large XML files rather than a database, and I'm happy with how it works.

    Dave

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,384
    Personally, I'd always go with the database approach, except in the absolute simplest and smallest of situations where I'm positive it's never going to scale up to a case where I'll be sorry I didn't make it a database to begin with. A DB also gives you many more options for efficiently selecting, grouping, and sorting your data on the fly, while with an XML approach you'd have to do all those things in your PHP code using SimpleXML or DOM methods, various array functions and so forth: much less efficiently than a properly configured DB could do it, especially as the data set grows.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Sep 2004
    Location
    At the corner of WALK and DONT WALK
    Posts
    1,714
    Well, my biggest frustration with databases is some of the pictures that are on my site have REALLY long descriptions, and using the text fields can be a pain. I figured, if I'm gonna have a text file, I might as well keep the whole shebang in that file.

  5. #5
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,384
    Quote Originally Posted by Mr Initial Man View Post
    Well, my biggest frustration with databases is some of the pictures that are on my site have REALLY long descriptions, and using the text fields can be a pain. I figured, if I'm gonna have a text file, I might as well keep the whole shebang in that file.
    I may well be missing a piece of the puzzle here, but I don't see where text size matters -- unless you're talking about editing text in phpMyAdmin or similar? If that's the issue, I would just build a simple admin/maintenance form with textarea fields of whatever size I want.

    I suspect there's a comfort-level thing here, too, perhaps, as I know you've done a lot of stuff with XML/XHTML. I work with database stuff in PHP every day, so it's pretty second nature to me now. I may use text files (often JSON) for fairly static things such as configuration files; but for anything where I want to store, search, retrieve, and organize data, it's databases all the way for me.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  6. #6
    Join Date
    Sep 2004
    Location
    At the corner of WALK and DONT WALK
    Posts
    1,714
    Well, yeah--editing text and markup in phpMyAdmin is what I've been doing. Right now, my website is kind of a mix of XML and MySQL--XML for the text, MySQL for the rest

  7. #7
    Join Date
    May 2013
    Location
    Kansas City
    Posts
    21
    XML is very useful, if you're doing data mining. It's a good interchange format. There's near universal support for it. It's great for pushing or getting information to and from other places. Like if you're using Soap Client, or aggregating/consuming RSS feeds. For those kinds of uses, it's often easier and more secure to use xml for your data. I wouldn't use it locally if I'm not dumping or consuming dumps of data because it has more overhead on the app server side of things, and I wouldn't want my site to be slower than it absolutely needs to be. If I was using xml as a back end for a website, I would use some kind of caching system, so the site performs a little better, and you don't need to do the heavy lifting every time a page loads.

  8. #8
    Join Date
    May 2013
    Location
    London, UK
    Posts
    16
    Go with the MySQL database. Every day of the week.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles