simple join
simple join
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
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
This discussion has been closed.
Replies
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
Thanks
Are you able to mail me the updates also?
Thank you!