Database CRUD with JavaScript

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
beandog
Forum Newbie
Posts: 1
Joined: Thu Nov 04, 2010 2:55 pm

Database CRUD with JavaScript

Post by beandog »

What do you guys do if you want to access your database directly, using JavaScript stuff (normally AJAX)? Using PHP as an intermediate layer, I mean.

I'm looking at building a REST API to access everything using AJAX, but I'm not sure if that's overkill or not, when I just need to get a few things.
User avatar
saltwine
Forum Newbie
Posts: 16
Joined: Tue Nov 09, 2010 7:05 am
Location: London

Re: Database CRUD with JavaScript

Post by saltwine »

That does sound like overkill to me.

You only want to build an entire API if you want to expose access to functionality from a different domain.

If you're accessing your database on the same server, you just need some PHP scripts that will connect to your database, accept GET/POST data or retrieve the data you want, and optionally spit it out information as JSON.

Then if you're using a framework such as MooTools or jQuery, you can simply ping those scripts with GET/POST data and you've got all the CRUD you need!
Post Reply