Personal computing discussed

Moderators: renee, SecretSquirrel, just brew it!

 
Majiir Paktu
Gerbil First Class
Topic Author
Posts: 114
Joined: Thu Feb 07, 2008 7:16 pm

XML over SQL? (With PHP, XSL, XHTML, and a dash of Apache?)

Sun Jun 15, 2008 3:59 pm

So I got this crazy idea.

I'm writing a simple blog site, and I want to be able to use a single data source, which my scripts (PHP) then use to generate XHTML pages, RSS feeds, e-mail formatted messages, et cetera. Now, I started to write it using PHP+MySQL, but I started running into problems; for example, in my RSS feeds I want to show different content than on my main site, some of my articles contain executable PHP code (Yeah, I know, it's jackass, but I want it there. My website after all.) and SQL just seems a bit messy to me. It works great for some things, but... a personal blog?

So I thought, 'why not store everything in an XML file, let PHP process that file to deal with any generated tidbits I put in the posts, and then use an XML stylesheet to format the content for whatever I want to display?' I then shot down my own idea by saying "well, not all browsers will support XSLT..." but then I again realized that I could use PHP to perform the transformations for me.

Is there any reason this is jackass? I was thinking I'd keep the file inside my /includes/ folder, which is only accessible to the server host itself (as per my .htaccess file). As of now I don't see any reason to not manually exit the XML and upload it periodically, but it shouldn't be an issue to write a script which writes to the XML file later.

Am I being dumb? Am I a genius?
 
steelcity_ballin
Gerbilus Supremus
Posts: 12072
Joined: Mon May 26, 2003 5:55 am
Location: Pittsburgh PA

Re: XML over SQL? (With PHP, XSL, XHTML, and a dash of Apache?)

Sun Jun 15, 2008 5:35 pm

i don't understand why you can't use a SQL database too do this anyhow - XML shouldn't really offer any advantages in this area. If you want different content for RSS just make a new column for it in the same table as the regular content and use the ID as your unique identifier. So simplifying things maybe you have a table with rows ID, CONTENT, RSSCONTENT and pull from there. A database will also be much more easily maintained and updated etc. Consider long term content updates when you have more than 50+ articles. That 1 XML file is going to get ugly.
 
emorgoch
Gerbil Elite
Posts: 719
Joined: Tue Mar 27, 2007 11:26 am
Location: Toronto, ON

Re: XML over SQL? (With PHP, XSL, XHTML, and a dash of Apache?)

Sun Jun 15, 2008 11:03 pm

I'm reminded of this blog entry: http://www.codinghorror.com/blog/archives/001114.html. Not purely relevant to your case, but a worthwhile read anyways.

But in the end, I come to this logic: if XML can do it, a real database can do it, and probably do it better. Databases have a HUGE speed advantage compared to large XML files. And if you decide to go with multiple small XML files, i.e. a single file per entry, well then you end up with having to deal with multiple files, and trying to keep them all in sync, etc. At the very least, you can store the XML text inside a text field in the database, then apply transforms after when you get the data back out.

Seems to me that the root of your problem is designing an adequate table structure. Take some time, sit back and think things through, then fully diagram out what you think your database should look like. In any project involving a database, hammering out a complete database design, and then implementing that design is the very first thing I do before I start any of the more front end stuff so that I have a solid foundation to build up from.
Intel i7 4790k @ stock, Asus Z97-PRO(Wi-Fi ac), 2x8GB Crucial DDR3 1600MHz, EVGA GTX 1080Ti FTW3
Samsung 950 Pro 512GB + 2TB Western Digital Black
Dell 2408WFP and Dell 2407WFP-HC for dual-24" goodness
Windows 10 64-bit
 
Madman
Minister of Gerbil Affairs
Posts: 2317
Joined: Tue Apr 01, 2003 4:55 am
Location: Latvia

Re: XML over SQL? (With PHP, XSL, XHTML, and a dash of Apache?)

Sun Jun 15, 2008 11:20 pm

People tend to overuse XML, some think it's the solution to all world problems, well it's not :wink:
Core 2 Duo E6300, MSI P45 NEO-F, Club 3D GTX 260, 4Gb DDR2-800Mhz, Audigy X-Fi Fatal1ty Champ1on ed., 0.5Tb+1Tb Seagate Barracuda 7200.12, 630W AXP, Samsung SyncMaster BX2450, ViewSonic VP171b

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On