I got an app to call api in my server for loading the data. This make sense to use asynchronous methods for loading the data. I don't want the whole UI is locked for waiting the data. But I found
It won't works. I found the reason is all Asynchronous methods are executed by a different thread. You have to call UI main thread to bind the data to UI.
I built a wordpress plug-in. The plug-in is working fine in a server, but another server returned an error about '[. I compared the two servers. Their php is different. The problematic server got old version of php which is php .5.3. Then I read the php specification. The Square Bracket array declaration which used in C# and Java is only available on Php >=5.4. So I have to change square brackets to array(). Then it works fine.
You can access the database via WordPress. You can use any raw SQL too. That is quite easy. You only need to call a global object;
For the raw SQL, you can use query method:
SET post_parent = 10
WHERE ID = 15
For get the record set,
$drafts = $wpdb->get_results(
WHERE post_status = 'draft'
AND post_author =1
There are insert, update and delete method too.
Please read WordPress development documentation for the further information
Although WordPress got its own JSON API, you still have your own JSON API for your own plugin and serialize your own data. That is not a problem. WordPress library got a function to serialize any objects to JSON Format. That is very easy. You can use this function in any parts of your plug-in.
I used Wordpress as the development framework for a mobile application project. Wordpress has a set of XMLPRC api for a very long time. Moreover, the mainstream in Mobile development is to use JSON as the communication format, rather than XML. JSON is smaller and easier to deserialize back to an object. Originally, I planned to use a third party plug-in for REST API and with my own code to build my own version REST API for my mobile application. Today, I checked my WordPress; It got an update for WordPress 4.7. After the updates, I found this version finally got an official REST API. That is great. I can build my code on top of that!
You can check this demo from Wordpress