Jump to content

Javascript and XML vs PHP and MySQL


iwato

Recommended Posts

QUESTION: Can one achieve everything with PHP and MySQL that one could ever want to achieve with Javascript and the XML DOM object? If not, what does the XML DOM object offer that MySQL does not and how are these complementary? Then too, maybe I am posing the wrong questions altogether. Please see below.BACKGROUND: When I first started learning PHP is was with the idea of building a webserver with dynamic webpages. Knowing that I would eventually want to add a database to my server I downloaded MAMP, purchased MAMP-Pro, and prepared for the inevitable -- learning how to use write in still another program language, namely, MySQL. Along the way, however, and even much before, I encountered XML. It would appear that learning both MySQL and XML are somewhat redundant. This said, XML does not appear to be very difficult, and I envision having to access all different kinds of databases to fill my own as time passes.Roddy

Link to comment
Share on other sites

If you think of XML as a database, then yes, it's redunant. However, it's not. XML is a set of rules for defining markup languages. A basic syntax if you will. Outside of using XML as a database, you may use it to define your own templating engine, your own BBCode alternative (at least those are the things I use it for), or simply not define anything, but just use the APIs to process 3rd party languages defined as XML, such as RSS, XHTML and SVG files.It's also worth noting that JavaScript can't write files to the server or access data on external domains, so even if you avoid using MySQL, avoiding PHP is impossible if you want to do anything more creative.

Link to comment
Share on other sites

If you think of XML as a database, then yes, it's redunant. However, it's not. XML is a set of rules for defining markup languages. A basic syntax if you will. Outside of using XML as a database, you may use it to define your own templating engine, your own BBCode alternative (at least those are the things I use it for), or simply not define anything, but just use the APIs to process 3rd party languages defined as XML, such as RSS, XHTML and SVG files.It's also worth noting that JavaScript can't write files to the server or access data on external domains, so even if you avoid using MySQL, avoiding PHP is impossible if you want to do anything more creative.
If I have understood correctly, I can do everything with Javascript, XML, and PHP that I can do with PHP and MySQL, but I cannot do everything with PHP and MySQL that I can do with Javascript, XML, and PHP. Is this what you are saying?Roddy
Link to comment
Share on other sites

PHP is perfectly capable of manipulating DOM structures by itself, through the use of the DOMDocument class.XML and relational databases (such as those that expose SQL interfaces) are just different types of data storage mechanisms. Relational systems aim to create two-dimensional tables of data consisting of fields, and records, and then indicating relations between different tables, while on the other hand XML defines a tree structure of directly descending child nodes, each of which contain data.You can do whatever you want with either system, but each suits some applications more than the other.

Link to comment
Share on other sites

If I have understood correctly, I can do everything with Javascript, XML, and PHP that I can do with PHP and MySQL, but I cannot do everything with PHP and MySQL that I can do with Javascript, XML, and PHP. Is this what you are saying?
In theory, yes. In practice, as Synook said, each [thing] suits some applications better than the other.PHP is most suitable for defining action stuff (writing to files, DBs, sending mails, etc.).JavaScript is most suitable for defining user interaction stuff (which, if involving action can happen by a request to PHP).MySQL and the like are most suitable for storing relational data, which is the kind of data found in most systems, such as this forum or, say, IMDB.com.XML is most suitable for defining custom data formats (i.e. markup languages), if you need ones for your applications. If you don't need ones, you can still use XML APIs to manipulate existing XML data formats.
Link to comment
Share on other sites

In theory, yes. In practice, as Synook said, each [thing] suits some applications better than the other.
Alas, I need them all and with CSS added on I can use AJAX.My journey shall be long. So, I must dig in.Thanks everyone!Roddy
Link to comment
Share on other sites

I dont understand why there is an ultimatum being proposed here. PHP and MYSQL can be considered server-side as the user will only see what you choose to show them and cannot view everything else inside a database or the PHP code you use. Javascript and XML are almost entirely if not entirely client-side. There are things PHP can do that Javascript can do but to even compare the two is trivial.I have been using all 4 technologies to be honest, and they usually compliment each other, not substitute.If you want database storage and manipulation then use PHP and MYSQL. If you want to get that database information dynamically then you can use javascript to fetch it through AJAX. XML can play other roles but it wont be too often when you nned to use all 4 for one particular function.Also keep in mind when it comes to security or preventing cheating etc... server-side scripting is almost a must since it would be monumentally more difficult to cheat a system scripted server-side than it is for a system scripted client-side.

Link to comment
Share on other sites

I was actually going to post something similar to this, so if you don't mind me posting a question Roddy, I think it would fit well in this thread.For my website I'm developing now, it is based around music recording, in particular bands I've recorded. I would like to be able to access mp3's and photos on the server and use PHP to automate the process of displaying them in the browser within an HTML document, for use in either a photo gallery or for use in some sort of mp3 player widget to play the songs. The question(s):Which would be the best way to store all the songs/photos, as well as info like title, description, etc. More so for the photos, I would like to be able to somehow use a directory browsing function to just target a directory and say, "get all these photos (image1.jpg, image2.jpg, etc)" and then use that as the src for an <img> tag. But if I could do that with the songs too that would be cool.Or, would I have to make a table for all songs, and one for all photos? Or would I better off using XML to store the URL's for the content, title, description, etc by album (music or photo) and then use PHP to parse it? How do most CMS like sites go about accomplishing this kind of task?Anyway, I thought this post might be appropriate for this thread as it relates to the pro's/cons of XML and PHP/SQL, but if it should be in its own thread, I'll make it so. Thanks folks.

Link to comment
Share on other sites

I was actually going to post something similar to this, so if you don't mind me posting a question Roddy, I think it would fit well in this thread.For my website I'm developing now, it is based around music recording, in particular bands I've recorded. I would like to be able to access mp3's and photos on the server and use PHP to automate the process of displaying them in the browser within an HTML document, for use in either a photo gallery or for use in some sort of mp3 player widget to play the songs. The question(s):Which would be the best way to store all the songs/photos, as well as info like title, description, etc. More so for the photos, I would like to be able to somehow use a directory browsing function to just target a directory and say, "get all these photos (image1.jpg, image2.jpg, etc)" and then use that as the src for an <img> tag. But if I could do that with the songs too that would be cool.Or, would I have to make a table for all songs, and one for all photos? Or would I better off using XML to store the URL's for the content, title, description, etc by album (music or photo) and then use PHP to parse it? How do most CMS like sites go about accomplishing this kind of task?Anyway, I thought this post might be appropriate for this thread as it relates to the pro's/cons of XML and PHP/SQL, but if it should be in its own thread, I'll make it so. Thanks folks.
What flash player are you using to play the songs? Most pre-built players expect and XML response for loading a song/playlist.If you want to be able to add/remove to your image and song database then PHP/MySQL would be the technologies of choice.As for the database structure, I would definitely split up the songs from the images.Even if the player you use expects an XML response, you can send one with PHP from data you get from your MySQL database.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...