Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

First, apologies in advance if this is in the wrong place - I wasn't sure if it should be here or in Code Review, but as I'm not actually asking for anyone to review my code . . .

Here's my project: Mostly as a learning exercise I am writing my own blog engine. Here's how it works:

Admin writes post - > post is saved to .html file, and details of post are written BOTH to a MySQL database and a JSON file using PHP - > posts are loaded onto site via iframes, determined by JavaScript using the details in the JSON file.

Thus for loading posts onto the site, no PHP or access to the database is required. The only reason for the database at all is to have an editable record so that if the admin needs to delete a post, the entry can be removed from the database and the JSON file re-written from the database.

What I want to know: 1) This seems a bit cumbersome. Would people recommend doing away with the JSON and making more use of the database? How do I integrate this with JavaScript stuff? 2) Is storing each post as a separate .html file and loading as an iframe a reasonable way of doing things? 3) Is there any way to cut out the PHP entirely? I am not keen on it really. I am starting to learn Python, but it seems an awful palaver for a small blog engine.

As you can probably tell, I am VERY new to programming! I have looked into TaffyDB, which in theory could get rid of the database entirely - I load the JSON with Taffy, remove one record, and re-write the JSON . . . except I'd still need PHP to write to file I think? Also, I am worried that relying entirely on JSON files will make things very slow (I understand speed issues increase exponentially with JSON size?)

Any advice/feedback would be welcome, and again I apologise if I'm posting in the wrong bit of StackExchange.

share|improve this question
 
"Everything you are doing is bad. I want you to know this." youtube.com/watch?v=ncGHiVKJh0Y –  Mathew Foscarini Dec 31 '13 at 0:59
 
Oi vell we live and learn :p –  Feathers Jan 1 at 1:11
add comment

1 Answer

You are overcomplicating things.

The best advice I can give for this is to not be afraid of relying on the database. They exist for the very purpose of managing information. For the vast number of applications, you will not notice a difference between access times when the data is pulled from the file system and when it comes from a database.

Regading iframes, there's no reason to use them here. Either generate the page in its entirety, or use Ajax to insert html where you want it. Among the many problems with iframes is that you cant bookmark them.

share|improve this answer
 
If it makes no difference to speed then I COULD use JSON + Taffy instead? I actually like MySQL (I enjoy designing tables . . . weird I know) I just dislike PHP and adore all things Javascript-y :p) –  Feathers Dec 30 '13 at 21:44
 
Although that would then undermine your second piece of advice, so never mind . . . PHP it is :-( –  Feathers Dec 30 '13 at 21:45
 
Sorry thinking as I type here . . . if each blog post was in a separate text file, I could then use that + JavaScript to load the post? Although I would then have the same problem with bookmarking? –  Feathers Dec 30 '13 at 21:46
 
If you are just starting out in programming, I'd recommend MySQL because its very widely used and you're very likely to encounter it if you start programming for a living. –  GrandmasterB Dec 30 '13 at 21:48
 
You'd still have the bookmarking problem that way (separate files). While that technique is used a lot (such as in a webmail client), its not the best for a blog. –  GrandmasterB Dec 30 '13 at 21:52
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.