I'm looking for some advice on how to connect to a MySQL database in my Ember application. I've created a dashboard with some charts using ZingChart's ember-zingchart addon, and my chart configuration JSON packets are kept in the associated controller for each template. I would need to query the db for different sets of data stored in the same table for each tab of my dashboard. Should I use PHP to connect to the database? If so, where would I place the PHP code for each template and how would I get the retrieved data into my controller? I'm still new at Ember, so if someone could nudge me in the right direction, that would be very helpful!
1 Answer
Ember is front end only. If you are looking to connect your front end app to a server side database, you must write some sort of RESTful API that preferably uses JSON as the data transport format from client (front end) to server (back end).
You can write your API in any language you wish. Any code you write will not be a part of your Ember app codebase.
Once you have your API written you will access it with AJAX calls, either via Ember Data or using jQuery's $.ajax directly in your Route's model hook.
I know this is a high level response, but I get the feeling your missing some fundamental concepts about the client/sever relationship.