lefJoin not updating on edit
lefJoin not updating on edit
Restful Web Services
Posts: 202Questions: 49Answers: 2
I cannot get a simply leftJoin to update. The parent table is updated but the joined table is not. When I run it with debug on it lokos to me like maybe the set procedure for the joined table is missing. Can anyone see what I am doing wrong?
The joined table displays the value correctly but just wont update.
Thanks
Chris
// include
include( "lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Mjoin,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 't_clientowner', 'iClientOwnerId' )
->fields(
Field::inst( 't_clientowner.iClientOwnerId' ),
Field::inst( 't_clientowner.user_id' ),
Field::inst( 't_clientowner.sAddress' ),
Field::inst( 'cms_module_feusers_users.username' )
)
->leftJoin('cms_module_feusers_users', 'cms_module_feusers_users.id ', '=', 't_clientowner.user_id')
->debug(true)
->process( $_POST )
->json();
Form data:
action:edit
data[row_8544][t_clientowner][sAddress]:editing
data[row_8544][cms_module_feusers_users][username]:testing
Debug response:
{
"data":[
{
"DT_RowId":"row_8544",
"t_clientowner":{
"iClientOwnerId":"8544",
"user_id":"1419",
"sAddress":"editing"
},
"cms_module_feusers_users":{
"username":"test"
}
}
],
"debug":[
{
"query":"SELECT * FROM `t_clientowner` WHERE `t_clientowner`.`iClientOwnerId` = :where_0 ",
"bindings":[
{
"name":":where_0",
"value":"8544",
"type":null
}
]
},
{
"query":"UPDATE `t_clientowner` SET `sAddress` = :sAddress WHERE `t_clientowner`.`iClientOwnerId` = :where_0 ",
"bindings":[
{
"name":":sAddress",
"value":"editing",
"type":null
},
{
"name":":where_0",
"value":"8544",
"type":null
}
]
},
{
"query":"SELECT `t_clientowner`.`iClientOwnerId` as 't_clientowner.iClientOwnerId', `t_clientowner`.`user_id` as 't_clientowner.user_id', `t_clientowner`.`sAddress` as 't_clientowner.sAddress', `cms_module_feusers_users`.`username` as 'cms_module_feusers_users.username' FROM `t_clientowner` LEFT JOIN `cms_module_feusers_users` ON `cms_module_feusers_users`.`id` = `t_clientowner`.`user_id` WHERE `t_clientowner`.`iClientOwnerId` = :where_0 ",
"bindings":[
{
"name":":where_0",
"value":"8544",
"type":null
}
]
}
]
}
This discussion has been closed.
Answers
Sorry, my mistake. I was forgetting to submit the id of the item in the join with my form post.
It is now working.
Thanks for the update - good to hear you've got it working.
Allan