Calling the PHP editor library to add/edit and remove fields
Calling the PHP editor library to add/edit and remove fields
Dear all,
I found the PHP editor library particularly clever and I am trying to use it also for an iPad app I am building.
I need to call directly the PHP class to add, edit and remove fields.
I wrote this piece of code and it worked. I get data into the corresponding table.
function test () {
var o = {};
var data = {};
data['type_id'] = 'WEIGHT';
data['child_id'] = 11;
data['device_date_time'] = '2015-11-10 22:22:22';
data['value'] = 12.76;
o['0'] = data;
$.post('_php/appLogs.php',
{
action: 'create',
data: o,
mobile_token : 'aa14c3be00a71b0fb7ec5d1caf8541cbca03cc2c',
from_date : '2015-10-16',
to_date: '2015-10-16 23:59:59'
},
function(data, status) {
//obj = JSON.parse(data);
console.log(data);
}
);
};
Now I have 2 issues:
1) I dnot receive back a data object with tne record created;
2) if I add into the PHP file a ->leftJoin statement, when I run the example I get this error:
Fatal error: Call to a member function insertId() on null in /Users/fabio_beretta/Sites/LutinRouge_admin/vendor/Editor-1.5.1/php/Editor/Editor.php on line 1357
What am I doing wrong?
this is the PHP file:
if ($login->isUserLoggedIn() == true) {
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'log', 'log.id' )
->fields(
Field::inst( 'log.type_id' ),
Field::inst( 'log.description' ),
Field::inst( 'log.value' ),
Field::inst( 'log.log_date_time' ),
Field::inst( 'log.device_date_time' ),
Field::inst( 'log.child_id' ),
Field::inst( 'log.photo_id' ))
->leftJoin( 'child', 'child.id', '=', 'log.child_id' )
->where( 'child.account_id', $_id )
->where( 'log.log_date_time', $_from_date, '>=' )
->where( 'log.log_date_time', $_to_date, '<=' )
->process( $_POST )
->json();
} else {
// Return errors and messages if the login failed
$_obj ['errors'] = $login->errors;
$_obj ['messages'] = $login->messages;
echo json_encode($_obj);
};
Thanks,
f
This question has an accepted answers - jump to answer
Answers
1 - The data might not be returned if the
where
conditions that you are applying to the table do not match against the newly created row. Might that be the case?2 - I'm not sure I've encountered this particular issue before - I'm afraid I don't have an immediate answer for it. The error suggests that either an SQL error occurred (in which case I would have expected a different error (is there one?) or that there are no values to set in the master table.
Are you able to give me a link to the page so I can take a look?
Allan