How to inner join query in ssp.class
How to inner join query in ssp.class
I need help to be able to join 2 table to get another field and show
// DB table to use
$table = "usuario_vod";
$joinQuery = "FROM '{$table}' AS uv LEFT JOIN usuario AS ud ON (ud.cve=uv.cve_dealer)";
$extraWhere = "";
// Table's primary key
$primaryKey = 'cve';
// Array of database columns which should be read and sent back to DataTables.
// The db
parameter represents the column name in the database, while the dt
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 'vd.usuario', 'dt' => 0),
array( 'db' => 'vd.apodo', 'dt' => 1),
array( 'db' => 'vd.status', 'dt' => 2 ),
array( 'db' => 'vd.fecha_vencimiento', 'dt' => 3,
'formatter' => function( $d, $row ) {
return date( 'd/M/Y', strtotime($d));
}
),
array( 'db' => 'ud.usuario', 'dt' => 4 ),
array( 'db' => 'vd.idu_dispositivo', 'dt' => 5),
array( 'db' => 'vd.cve_dealer', 'dt' => 6)
);
// SQL server connection information
$sql_details = array(
'user' => 'ro',
'pass' => '',
'db' => 'r',
'host' => 'localhost'
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP
* server-side, there is no need to edit below this line.
*/
require( 'ssp.class.php' );
echo json_encode(
Ssp::simple( $_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery, $extraWhere)
);
my query
SELECT
uv.*,
ud.usuario AS dealer
FROM usuario_vod AS uv LEFT JOIN usuario AS ud ON (uv.cve_dealer=ud.cve)