simple join

simple join

jgcaudetjgcaudet Posts: 77Questions: 5Answers: 0
edited May 2013 in Editor
Hi Allan.
I want to show in your datatables+editor, a simple join between two tables. The parent table "tritecno_categorias_mayorista" has a field "mayorista_id" that point to a field "mayorista_id" that is a primary key in the child table "tritecno_mayoristas". I dont want to modify any field in the child table, only show some fields of this child table.

I use this code

$editor = Editor::inst( $db, 'tritecno_categorias_mayorista' )
->fields(
Field::inst( 'mayorista_id' )->set( false )->validator( 'Validate::required' ),
Field::inst( 'mayorista_categoria_id' )->set( false )->validator( 'Validate::required' ),
Field::inst( 'categoria_mayorista' )->set( false )->validator( 'Validate::required' ),
Field::inst( 'subcategoria_mayorista' )->set( false ),
Field::inst( 'virtuemart_category_id' )->validator( 'Validate::required' )
)
->join(
Join::inst( 'tritecno_mayoristas', 'object' )
->join( 'mayorista_id', 'mayorista_id' )
->table('tritecno_mayoristas')
->set( false )
->field(
Field::inst( 'tritecno_mayoristas.mayorista_acro', 'mayorista_acro' )->set( false )
)
)
;


I recieve this error :
DataTables warning (table id = 'example'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.

and in firefox debug the answer to the get.php is this message
Warning: require(C:\xampp\htdocs\tritecno\php\lib/Exception/Exception.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\tritecno\php\lib\Bootstrap.php on line 40

However If I do this with another child table "ddqfu_virtuemart_categories_es_es" but the same parent table "tritecno_categorias_mayorista", it works. In yhis case I use this parent field "virtuemart_category_id" that point to a field "virtuemart_category_id" in the child table "ddqfu_virtuemart_categories_es_es" that is primary key.

The code that works :

$editor = Editor::inst( $db, 'tritecno_categorias_mayorista' )
->fields(
Field::inst( 'mayorista_id' )->set( false )->validator( 'Validate::required' ),
Field::inst( 'mayorista_categoria_id' )->set( false )->validator( 'Validate::required' ),
Field::inst( 'categoria_mayorista' )->set( false )->validator( 'Validate::required' ),
Field::inst( 'subcategoria_mayorista' )->set( false ),
Field::inst( 'virtuemart_category_id' )->validator( 'Validate::required' )
)
->join(
Join::inst( 'ddqfu_virtuemart_categories_es_es', 'object' )
->join( 'virtuemart_category_id', 'virtuemart_category_id' )
->table('ddqfu_virtuemart_categories_es_es')
->set( false )
->field(
Field::inst( 'ddqfu_virtuemart_categories_es_es.category_name', 'category_name' )->set( false )
)
;

Is the code that I use correct to get the result I want ? If is correct, why in the first case doesn,t works ?

Thanks

Replies

  • allanallan Posts: 56,187Questions: 1Answers: 8,897 Site admin
    There is a bug in the current Editor release, unfortunately, which obscures the actual error. The Exception error coming from the Bootstrap file is because there is a missing global namespace identifier. Can I mail you the updated libraries at the e-mail address you used to sign up to the DataTables forums?

    With that update, we'll be able to see what the exception actually is, and be able to determine more accurately what is going on!

    Thanks,
    Allan
  • jgcaudetjgcaudet Posts: 77Questions: 5Answers: 0
    yes
  • squaredicesquaredice Posts: 1Questions: 0Answers: 0
    Hey Allan, are you able to post or mail me the update as well?

    Thanks
  • x3blisx3blis Posts: 1Questions: 0Answers: 0
    Hi Allan.
    Are you able to mail me the updates also?

    Thank you!
This discussion has been closed.