join not working
join not working
THis returns error 500
[code]
<?php
/*
* Editor server script for DB table caseinfo
* Automatically generated by http://editor.datatables.net/generator
*/
// DataTables PHP library
include( "lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use DataTables\Editor;
use DataTables\Editor\Field;
use DataTables\Editor\Format;
use DataTables\Editor\Join;
use DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'caseinfo' )
->fields(
Field::inst( 'casename' ),
Field::inst( 'casetype' ),
Field::inst( 'factsnum' ),
Field::inst( 'socialsecurity' )
->validator( 'Validate::maxLen', 4 ),
Field::inst( 'primdob' )
->validator( 'Validate::dateFormat', 'D, j M y' )
->getFormatter( 'Format::date_sql_to_format', 'D, j M y' )
->setFormatter( 'Format::date_format_to_sql', 'D, j M y' ),
Field::inst( 'id' ),
Field::inst( 'userid' ),
Field::inst( 'agencyid' )
)
->join(
Join::inst( 'users', 'object' )
->join( 'userid','member_id' )
->field(
Field::inst( 'fname' )
)
//->where($a, $b, $c)
->process( $_POST )
->json();
?>
[/code]
I also notice in this documentation you tend to use
->field ()
->fields()
interchangeably.
http://editor.datatables.net/tutorials/php_join
Am I missing something ?
[code]
<?php
/*
* Editor server script for DB table caseinfo
* Automatically generated by http://editor.datatables.net/generator
*/
// DataTables PHP library
include( "lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use DataTables\Editor;
use DataTables\Editor\Field;
use DataTables\Editor\Format;
use DataTables\Editor\Join;
use DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'caseinfo' )
->fields(
Field::inst( 'casename' ),
Field::inst( 'casetype' ),
Field::inst( 'factsnum' ),
Field::inst( 'socialsecurity' )
->validator( 'Validate::maxLen', 4 ),
Field::inst( 'primdob' )
->validator( 'Validate::dateFormat', 'D, j M y' )
->getFormatter( 'Format::date_sql_to_format', 'D, j M y' )
->setFormatter( 'Format::date_format_to_sql', 'D, j M y' ),
Field::inst( 'id' ),
Field::inst( 'userid' ),
Field::inst( 'agencyid' )
)
->join(
Join::inst( 'users', 'object' )
->join( 'userid','member_id' )
->field(
Field::inst( 'fname' )
)
//->where($a, $b, $c)
->process( $_POST )
->json();
?>
[/code]
I also notice in this documentation you tend to use
->field ()
->fields()
interchangeably.
http://editor.datatables.net/tutorials/php_join
Am I missing something ?
This discussion has been closed.
Replies
Thanks,
Allan
[code]
Editor::inst( $db, 'caseinfo' )
->fields(
Field::inst( 'casename' ),
Field::inst( 'casetype' ),
Field::inst( 'factsnum' ),
Field::inst( 'socialsecurity' )
->validator( 'Validate::maxLen', 4 ),
Field::inst( 'primdob' )
->validator( 'Validate::dateFormat', 'D, j M y' )
->getFormatter( 'Format::date_sql_to_format', 'D, j M y' )
->setFormatter( 'Format::date_format_to_sql', 'D, j M y' ),
Field::inst( 'id' ),
Field::inst( 'userid' ),
Field::inst( 'agencyid' )
)
//->where($a, $b, $c)
->process( $_POST )
->json();
/* ->join(
Join::inst( 'users', 'object' )
->join( 'userid','member_id' )
->fields(
Field::inst( 'fname' )
) */
?>
[/code]
[code]
->join(
Join::inst( 'users', 'object' )
->join( 'userid','member_id' )
->fields(
Field::inst( 'fname' )
)
[/code]
needed to be
[code]
->join(
Join::inst( 'users', 'object' )
->join( 'userid','member_id' )
->fields(
Field::inst( 'fname' )
)
)
[/code]
I also notice in this documentation you tend to use
->field ()
->fields()
interchangeably.
[/quote]
No you aren't missing anything - they are identical. The intention was that `field()` would be used to add a single field, while `fields()` would be used to add multiple fields with a single function call, but under the hood they are identical:
http://editor.datatables.net/docs/current/php/class-DataTables.Editor.html#_field
In DataTables 1.10, there will be `row()` and `rows()` for working on a single row, or multiple rows. These will not be identical, so plural does have meaning :-).
Allan