Delete not working
Delete not working
Hi,
I have joined 3-4 tables using the Datatables editor, but when I try to delete the row it is giving me the follwing error -
Notice: Undefined variable: ids in C:\xampp\htdocs\impact-map\html\survey\templates\dbadmin\Datatables-editor\php\Editor\Join.php on line 692
{"fieldErrors":[],"error":"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'org_profiles.profile_id' in 'where clause'","data":[],"ipOpts":[],"cancelled":[]}
Here is my code -
simple.html
var table = $('#example').DataTable( {
dom: "Bfrtip",
ajax: "../php/staff.php",
order: [[ 1, 'asc' ]],
"autoWidth": false,
"scrollY": 400,
"scrollX": true,
"scrollCollapse": true,
"pageLength": 50,
/* "paging": false,*/
columns: [
{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
},
//{ data: "org_profiles.profile_id", editField: "", "visible" : false},
{ data: "org_profiles.profile_id", editField: ""},
{ data: "org_profiles.org_name" },
{ data: "org_profiles.industry_id", editField: "org_profiles.industry_id"},
{ data: "org_profiles.industry_other" , editField: "org_profiles.industry_other"},
{ data: "org_profiles.org_description" },
{ data: "org_profiles.org_profile_status"},
{ data: "org_profiles.createdAt" , editField: "" },
{ data: "org_profiles.updatedAt" , editField: ""},
{ data: "org_profiles.org_additional" , editField: "org_profiles.org_additional"},
{ data: "org_profiles.org_confidence" , editField: "org_profiles.org_confidence"},
{ data: "org_profiles.org_greatest_impact" , editField: "org_profiles.org_greatest_impact"},
{ data: "org_profiles.org_greatest_impact_detail" , editField: "org_profiles.org_greatest_impact_detail"},
{ data: "org_profiles.org_profile_category" , editField: "org_profiles.org_profile_category"},
{ data: "org_profiles.org_profile_src" , editField: "org_profiles.org_profile_src" },
{ data: "org_profiles.org_profile_year" , editField: "org_profiles.org_profile_year"},
{ data: "org_profiles.org_type" , editField: "org_profiles.org_type"},
{ data: "org_profiles.org_type_other" , editField: "org_profiles.org_type_other"},
{ data: "org_profiles.org_url" , editField: "org_profiles.org_url"},
{ data: "org_profiles.org_year_founded" , editField: "org_profiles.org_year_founded" },
{ data: "org_profiles.machine_read" , editField: "org_profiles.machine_read"},
{ data: "org_profiles.org_size" },
{ data: "org_locations.org_hq_city", editField: ""},
{ data: "org_locations.org_hq_st_prov", editField: ""},
{ data: "org_contacts.survey_contact_email", editField: "org_contacts.survey_contact_email"},
{ data: "org_contacts.survey_contact_first", editField: "org_contacts.survey_contact_first"},
{ data: "org_contacts.survey_contact_last", editField: "org_contacts.survey_contact_last"},
{ data: "org_contacts.survey_contact_phone", editField: "org_contacts.survey_contact_phone"},
{ data: "org_contacts.survey_contact_title", editField: "org_contacts.survey_contact_title"},
{ data: "org_country_info.org_hq_country", editField: ""},
{ data: "org_country_info.org_hq_country_income", editField: ""},
/* { data: "org_country_info.org_hq_country_income_code", editField: ""},
{ data: "org_country_info.org_hq_country_locode", editField: ""},*/
{ data: "org_country_info.org_hq_country_region", editField: ""},
/* { data: "org_country_info.org_hq_country_region_code", editField: ""},
{ data: "org_country_info.ISO2", editField: ""},*/
{ data: "org_country_info.c_lat", editField: ""},
{ data: "org_country_info.c_lon", editField: ""},
{ data: "org_data_use", render: "[, ].data_type"},
{ data: "data_applications.advocacy", editField: "data_applications.advocacy"},
{ data: "data_applications.advocacy_desc", editField: "data_applications.advocacy_desc"},
{ data: "data_applications.org_opt", editField: "data_applications.org_opt"},
{ data: "data_applications.org_opt_desc", editField: "data_applications.org_opt_desc"},
{ data: "data_applications.use_other", editField: "data_applications.use_other"},
{ data: "data_applications.use_other_desc", editField: "data_applications.use_other_desc"},
{ data: "data_applications.prod_srvc", editField: "data_applications.prod_srvc"},
{ data: "data_applications.prod_srvc_desc", editField: "data_applications.prod_srvc_desc"},
{ data: "data_applications.research", editField: "data_applications.research"},
{ data: "data_applications.research_desc", editField: "data_applications.research_desc"}
],
keys: {
columns: ':not(:first-child)',
editor: editor
},
select: {
style: 'os',
selector: 'td:first-child'
},
buttons: [
// { extend: "create", editor: editor },
// { extend: "edit", editor: editor },
{ extend: "remove", editor: editor },
{
extend: 'colvis',
columns: ':not(.noVis)'
},
staff.php
Editor::inst( $db, 'org_profiles' )
->pkey( 'profile_id' )
->fields(
Field::inst( 'org_profiles.profile_id' ),
Field::inst( 'org_profiles.org_name' ),
Field::inst( 'org_profiles.org_description' ),
Field::inst( 'org_profiles.org_size' ),
Field::inst( 'org_profiles.org_profile_status' ),
Field::inst( 'org_profiles.industry_id' )
->validator( 'Validate::dbValues' ),
Field::inst( 'org_profiles.industry_other' ),
Field::inst( 'org_profiles.org_additional' ),
Field::inst( 'org_profiles.org_confidence' ),
Field::inst( 'org_profiles.org_greatest_impact' ),
Field::inst( 'org_profiles.org_greatest_impact_detail' ),
Field::inst( 'org_profiles.org_profile_category' ),
Field::inst( 'org_profiles.org_profile_src' ),
Field::inst( 'org_profiles.org_profile_year' ),
Field::inst( 'org_profiles.org_type' ),
Field::inst( 'org_profiles.org_type_other' ),
Field::inst( 'org_profiles.org_url' ),
Field::inst( 'org_profiles.org_year_founded' ),
Field::inst( 'org_profiles.createdAt' ),
Field::inst( 'org_profiles.updatedAt' ),
Field::inst( 'org_profiles.machine_read' ),
Field::inst( 'org_profiles.location_id' )
->options( Options::inst()
->table( 'org_locations' )
->value( 'location_id' )
->label( 'org_hq_city' )
)
->validator( 'Validate::dbValues' ),
Field::inst( 'org_locations.org_hq_city' ),
Field::inst( 'org_locations.org_hq_st_prov' ),
Field::inst( 'org_contacts.survey_contact_email' ),
Field::inst( 'org_contacts.survey_contact_first' ),
Field::inst( 'org_contacts.survey_contact_last' ),
Field::inst( 'org_contacts.survey_contact_phone' ),
Field::inst( 'org_contacts.survey_contact_title' ),
Field::inst( 'org_profiles.country_id' )
->options( Options::inst()
->table( 'org_country_info' )
->value( 'country_id' )
->label( 'org_hq_country' )
)
->validator( 'Validate::dbValues' ),
Field::inst( 'org_country_info.org_hq_country' ),
Field::inst( 'org_country_info.org_hq_country_income' ),
Field::inst( 'org_country_info.org_hq_country_income_code' ),
Field::inst( 'org_country_info.org_hq_country_locode' ),
Field::inst( 'org_country_info.org_hq_country_region' ),
Field::inst( 'org_country_info.org_hq_country_region_code' ),
Field::inst( 'org_country_info.ISO2' ),
Field::inst( 'org_country_info.c_lat' ),
Field::inst( 'org_country_info.c_lon' ),
Field::inst( 'data_applications.advocacy_desc' ),
Field::inst( 'data_applications.org_opt_desc' ),
Field::inst( 'data_applications.use_other_desc' ),
Field::inst( 'data_applications.prod_srvc_desc' ),
Field::inst( 'data_applications.research_desc' ),
Field::inst( 'data_applications.advocacy' ),
Field::inst( 'data_applications.org_opt' ),
Field::inst( 'data_applications.use_other' ),
Field::inst( 'data_applications.prod_srvc' ),
Field::inst( 'data_applications.research' )
)
->leftJoin( 'org_locations', 'org_locations.location_id', '=', 'org_profiles.location_id' )
->leftJoin( 'org_contacts', 'org_contacts.profile_id', '=', 'org_profiles.profile_id' )
->leftJoin( 'org_country_info', 'org_country_info.country_id', '=', 'org_profiles.country_id' )
->leftJoin( 'data_applications', 'data_applications.profile_id', '=', 'org_profiles.profile_id' )
//->leftJoin( 'org_data_use', 'org_data_use.profile_id', '=', 'org_profiles.profile_id' )
->join(
Mjoin::inst( 'org_data_use' )
->link( 'org_data_use.profile_id', 'org_profiles.profile_id' )
//->link( 'permission.id', 'user_permission.permission_id' )
//->order( 'name asc' )
->fields(
Field::inst( 'object_id' )
//->validator( 'Validate::required' )
->options( Options::inst()
->table( 'org_data_use' )
->value( 'profile_id' )
->label( 'data_type' )
),
Field::inst( 'data_type' )
)
)
->process( $_POST )
->json();
This question has an accepted answers - jump to answer
Answers
Can you confirm what version of Editor you are using please? And also that the PHP library versions match the client-side? And finally, can you show me your Javascript initialisation for the client-side Editor?
Sorry for all the questions
Allan
Sure, Allan. It's absolutely fine. Here are all the details. Kindly let me know if you need anything else -
DataTables Editor v1.6.1
Current PHP version: 5.6.30
Javascript initialisation for the client-side Editor
I used this post (http://byjm.datatables.net/forums/discussion/40454/editor-1-6-1-system-error-on-delete) by you to make the changes mentioned in the post, The Error now has changed to this -
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'org_profiles.profile_id' in 'where clause'
and staff.php is returned this json -
{fieldErrors: [],…}
cancelled:[]
data:[]
error:"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'org_profiles.profile_id' in 'where clause'"
fieldErrors:[]
ipOpts:[]
Could you update to Editor 1.6.2, both the client-side and server-side libraries please. There were a couple of fixes in this area which should help.
Thanks,
Allan
Sure. Could you tell me which files do I need to replace to upgrade from 1.6.1 to 1.6.2 ?
The Editor Javascript file (
dataTables.editor.js
and itsmin
counterpart) and all of the files in the PHP library for Editor, minus theconfig.php
file, which you should keep as you currently have.Allan
Brilliant. I upgraded all the files and multiple delete is now working. Thanks a ton for all your help! Really appreciate it!