Simple Join Query

Simple Join Query

notyou61notyou61 Posts: 21Questions: 8Answers: 0

Hello,

I am putting together a simple join query however am getting errors which I don't understand. My code is below:
HTML
// Actions Datagrid
$('#tblActions').DataTable({
dom: "Tfrtip",
lengthChange: false,
bAutoWidth: false,
jQueryUI: true,
bProcessing: true,
bServerSide: true,
ajax: {
url: "dataGridQuery.php",
data: { "gridNumber": 2 },
type: 'POST'
},
columns: [
{ title: "Action ID", data: "tblActions.actionID", width: "10%" },
{ title: "Time", data: "tblActions.actionTime" },
{ title: "Action Taken", data: "tblActions.actionTaken" },
{ title: "User", data: "tblUsers.userID" }
]
// tableTools: {
// sRowSelect: "os",
// aButtons: [
// { sExtends: "editor_create", editor: editor1 },
// { sExtends: "editor_edit", editor: editor1 },
// { sExtends: "editor_remove", editor: editor1 }
// ]
// }
});

PHP
// Obtain Action Grid
if(isset($_GET['gridNumber']) && $_GET['gridNumber']==2){
//
$data = Editor::inst( $db, 'tblActions' )
->field(
Field::inst( 'tblActions.actionID' ),
Field::inst( 'tblActions.actionTime' ),
Field::inst( 'tblActions.actionTaken' ),
Field::inst( 'tblActions.actionUserID' ),
Field::inst( 'tblUsers.userID' )
)
->leftJoin( 'tblUsers', 'tblUsers.userID', '=', 'tblActions.actionUserID' )
->process($_POST)
->data();
//
if ( ! isset($_POST['action']) ) {
// Get a list of sites for the select list
$data['tblUsers'] = $db
->selectDistinct( 'tblUsers', 'userID as value, userID as label' )
->fetchAll();
}
// Echo
echo json_encode( $data );
}

Errors
{"error":"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tblActions.id' in 'field list'","data":[],"tblUsers":[{"value":"1","label":"1"},{"value":"2","label":"2"}]}

DataTables warning: table id=tblActions - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

Thanks for any help.

This discussion has been closed.