Add record using mysql service with php


#1

I need to add a record using mysql service in a custom php server side script,

i try:
$payload = $event[‘request’][‘payload’];
$api = $platform[‘api’];
$post = $api->post;

$arr = array(‘id’ => 999);
$msg = [‘resource’ => $arr];

$result = $post(‘mysql/_table/todo’, ‘{“resource”: $arr}’);//none of these two rows
$result = $post(‘mysql/_table/todo’, $msg); //seem to be working

My todo table is a single column table, and from the swagger definitions of the mysql service i can add new data with this body successfully,

{“resource”: [{“id”:789}]}

Thanx in advance


#2

$userDetailsData = [‘provider_type’ => ($payload[‘provider_type’]),
‘provider_user_id’ => ($payload[‘provider_user_id’]),
‘user_id’ => ($userProfileGetCall[‘content’][‘id’])];

$userDetailsPostCall = $post(“mysql/_table/user_details”,$userDetailsData);

an example from my code. Also see what the log file in apps/dreamfactory/htdocs/storage/logs shows after you run your script.