mySQL join

mySQL join

nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
edited October 2012 in General
Hi,
I am following the tutorial to the letter, but in my own implementation,
1) My SELECT box is empty (edit/new)
2) I get a JS error:
Undefined is not an object (line 1617(
>>> var fieldType = Editor.fieldTypes[ fieldConf.type ];


#
The PHP code which I use

# Table layout

tblExerciseEquipment
EEquipmentID
EquipmentName
f_LanguageID

tblLanguages
> LanguageID
> LName

# PHP code

Editor::inst( $db, 'tblExerciseEquipment' )
->fields(
Field::inst( 'EquipmentName' )->validator( 'Validate::required' ),
Field::inst( 'f_LanguageID' )->validator( 'Validate::required' )
)
->join(
Join::inst('tblLanguages','object')
->join('f_LanguageID','LanguageID')
->fields(
//Field::inst( 'LanguageID' )->validator( 'Validate::required' ),
Field::inst( 'LName' ))
)
->pkey('EEquipmentID')
->process( $_POST )
->json();

# JS

editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "ajax_content_exerciseEquipment.php",
"domTable": "#tblExerciseEquipment",
"fields": [ {
"label": "Language:",
// The 'id' value from the property is used to set the value
// of the select list.
"name": "tblLanguages.LanguageID",
"type": "select"
},
{
"label": "Equipment name:",
"name": "EquipmentName"
}
]
} );

$('#tblExerciseEquipment').dataTable( {
"sDom": "Tfrtip",
"sAjaxSource": "ajax_content_exerciseEquipment.php",
"aoColumns": [

{
// Use the 'name' property from the 'dept' object in the
// JSON. It might not be set, so we also provide a default.
"mData": "tblLanguages.LName",
"sDefaultContent": ""
},
{ "mData": "EquipmentName" }
],
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]
},
"fnInitComplete": function ( settings, json ) {
// Set the allowed values for the select and radio fields based on
// what is available in the database
editor.field('dept.id').update( json.dept );
editor.field('access[].id').update( json.access );
}
} );

Replies

  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    Note:

    1) the tblExerciseEquipment is empty at the moment

    2) It's an inner join (e.g. SELECT EquipmentName,LName FROM tblExerciseEquipment,tblLanguages WHERE LanguageID = f_LanguageID)
  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    Through the XHR inspector in firebug, I see that there are 2 series of data missing in the sample code. Will review the enclosed samples instead of the incomplete code on the website.
  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    OK, so I've got the local examples to work. But I get the following error when updating a record for a second time (first time is OK).

    ###

    Notice: Undefined index: access in /Users/nathan/Sites/Physitrack.com/functions/datatables/Editor/Join.php on line 474

    {"id":"row_29","error":"","fieldErrors":[],"data":[],"row":{"DT_RowId":"row_29","first_name":"cHamilton","last_name":"Blackburn","dept":{"id":"3","name":"Pre-Sales"},"access":[],"extra":{"comments":"","review":""}}}
  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    In fact, the same error occurs on your own demo:
    http://editor.datatables.net/release/DataTables/extras/Editor/examples/join.html
  • allanallan Posts: 63,531Questions: 1Answers: 10,474 Site admin
    I'm not seeing that error I'm afraid.

    I have just released Editor 1.2.2 and it has number of bug fixes in it. I'd suggest updating to the new release and see if that addresses the issue for you. If not, can you link us to your page please?

    Allan
This discussion has been closed.