ssp icon indicating copy to clipboard operation
ssp copied to clipboard

this error LEFT JOIN

Open xoceunder opened this issue 7 years ago • 2 comments

Does not work

<?php

// DB table to use
$table = 'usuario_vod';
// Table's primary key
$primaryKey = 'cve';

$columns = array(
	array( 'db' => '`u`.`user`', 'dt' => 0, 'field' => 'user', 'as' => 'user' ),
	array( 'db' => '`u`.`contrasenia`',  'dt' => 1, 'field' => 'contrasenia' ),
	array( 'db' => '`u`.`pin`',   'dt' => 2, 'field' => 'pin' ),
	array( 'db' => '`u`.`status`',     'dt' => 3, 'field' => 'status'),
	array( 'db' => '`ud`.`user`',     'dt' => 4, 'field' => 'user', 'as' => 'user' ),
	array( 'db' => '`u`.`fecha_vencimiento`', 'dt' => 5, 'field' => 'fecha_vencimiento', 'formatter' => function( $d, $row ) {
																	return date( 'd-M-Y', strtotime($d));
																}),
	array('db'  => '`u`.`idu_dispositivo`',     'dt' => 6, 'field' => 'idu_dispositivo'),
	array('db'  => '`u`.`idu_dispositivo`',     'dt' => 7, 'field' => 'idu_dispositivo')
);
// SQL server connection information
require('config.php');
$sql_details = array(
	'user' => $db_username,
	'pass' => $db_password,
	'db'   => $db_name,
	'host' => $db_host
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * 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' );
require('ssp.customized.class.php' );
$joinQuery = "FROM `usuario_vod` AS `u` JOIN `usuario` AS `ud` ON (`ud`.`cve` = `u`.`cve_dealer`)";
$extraWhere = "";        
echo json_encode(
	SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery, $extraWhere )
);

In the user fields I throw the same data since they use the same field the 2 tables

xoceunder avatar Feb 18 '17 17:02 xoceunder

Replace Line 53 of ssp.customized.class.php Original: $row[ $column['dt'] ] = ($isJoin) ? $data[$i][ $columns[$j]['field'] ] : $data[$i][ $columns[$j]['db'] ]; Replace With: $row[ $column['dt'] ] = ($isJoin) ? (isset($columns[$j]['as']) ? $data[$i][ $columns[$j]['as'] ] : $data[$i][ $columns[$j]['field'] ]) : $data[$i][ $columns[$j]['db'] ];

techcalibrator avatar Mar 21 '17 05:03 techcalibrator

It would be better, if you can share your ERROR as well.

Thanks

emran avatar Jul 04 '17 17:07 emran