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.
Database CRUD with JavaScript
Moderator: General Moderators
Re: Database CRUD with JavaScript
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!
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!