using a where clause applied to a joined table field in Editor
using a where clause applied to a joined table field in Editor
Hi,
I'am trying unsuccessfully to applied a where clause on a joined table field with Editor.
Is there somebody you succed in such a query?
my code and thnks in advance for help!
Stephane
[code]
include( "../../DataTables/lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Validate;
/*
* Jointure de la table des locataires avec celle des centres
*/
$editor = Editor::inst( $db, 'locations' )
->field(
Field::inst( 'id' ) ,
Field::inst( 'nom_location' ) ,
Field::inst( 'Categorie' ) ,
Field::inst( 'Kilometrage' ) ,
Field::inst( 'avgkm' ) ,
Field::inst( 'Date_Msr' ) ,
Field::inst( 'Immatriculation' ),
Field::inst( 'Nserie' ) ,
Field::inst( 'color' ) ,
Field::inst( 'ede' ) ,
Field::inst( 'kmfirstrev' ) ,
Field::inst( 'sect' ) ,
Field::inst( 'etat_loc' )
)
->join(
Join::inst( 'centre', 'object' )
->join(
array( 'id' , 'id_pdt' ),
array( 'id' , 'id_ctr' ),
'pdt_ctr'
)
->field(
Field::inst( 'id' )->name('idctr'),
Field::inst( 'Centre' )
)
);
// The "process" method will handle data get, create, edit and delete
// requests from the client
$out = $editor
->where('idctr',19)
->process($_POST)
->data();
// When there is no 'action' parameter we are getting data, and in this
// case we want to send extra data back to the client, with the options
// for the 'centre' select list
if ( !isset($_POST['action']) ) {
$out['centre'] = $db
->select( 'centre', 'id as value, Centre as label' )
->fetchAll();
}
// Send it back to the client
echo json_encode( $out );
[/code]
I'am trying unsuccessfully to applied a where clause on a joined table field with Editor.
Is there somebody you succed in such a query?
my code and thnks in advance for help!
Stephane
[code]
include( "../../DataTables/lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Validate;
/*
* Jointure de la table des locataires avec celle des centres
*/
$editor = Editor::inst( $db, 'locations' )
->field(
Field::inst( 'id' ) ,
Field::inst( 'nom_location' ) ,
Field::inst( 'Categorie' ) ,
Field::inst( 'Kilometrage' ) ,
Field::inst( 'avgkm' ) ,
Field::inst( 'Date_Msr' ) ,
Field::inst( 'Immatriculation' ),
Field::inst( 'Nserie' ) ,
Field::inst( 'color' ) ,
Field::inst( 'ede' ) ,
Field::inst( 'kmfirstrev' ) ,
Field::inst( 'sect' ) ,
Field::inst( 'etat_loc' )
)
->join(
Join::inst( 'centre', 'object' )
->join(
array( 'id' , 'id_pdt' ),
array( 'id' , 'id_ctr' ),
'pdt_ctr'
)
->field(
Field::inst( 'id' )->name('idctr'),
Field::inst( 'Centre' )
)
);
// The "process" method will handle data get, create, edit and delete
// requests from the client
$out = $editor
->where('idctr',19)
->process($_POST)
->data();
// When there is no 'action' parameter we are getting data, and in this
// case we want to send extra data back to the client, with the options
// for the 'centre' select list
if ( !isset($_POST['action']) ) {
$out['centre'] = $db
->select( 'centre', 'id as value, Centre as label' )
->fetchAll();
}
// Send it back to the client
echo json_encode( $out );
[/code]
This discussion has been closed.
Replies