Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this error LEFT JOIN #13

Open
xoceunder opened this issue Feb 18, 2017 · 2 comments
Open

this error LEFT JOIN #13

xoceunder opened this issue Feb 18, 2017 · 2 comments

Comments

@xoceunder
Copy link

xoceunder commented Feb 18, 2017

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

@techcalibrator
Copy link

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'] ];

@emran
Copy link
Owner

emran commented Jul 4, 2017

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

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants