pixie icon indicating copy to clipboard operation
pixie copied to clipboard

Prefix added to join aliases

Open m-mohr opened this issue 7 years ago • 1 comments

When using a table prefix and join aliases, the prefix gets added to the aliases. I think this is a bug.

This example code:

$dbConfig = array(
	'driver'    => $config['dbsystem'],
	'host'      => $config['host'],
	'database'  => $config['database'],
	'username'  => $config['dbuser'],
	'password'  => $config['dbpw'],
	'charset'   => 'utf8mb4',
	'collation' => 'utf8mb4_unicode_ci',
	'prefix'    => $config['dbprefix'] // This is 'v_'
);
$db = new \Pixie\Connection($config['dbsystem'], $dbConfig, 'SQL');
\SQL::table(array('messages' => 'messages'))->leftJoin(array('user', 'alias'), "alias.id", '=', "messages.user_id")->get();

would generate something like this: SELECT * FROM v_messages AS messages LEFT JOIN v_user AS v_alias ON v_alias.id = v_messages.user_id but I think SELECT * FROM v_messages AS messages LEFT JOIN v_user AS alias ON alias.id = messages.user_id would be the logically expected version.

m-mohr avatar Apr 29 '17 01:04 m-mohr

i use db::raw for solve this

aliakbarazizi avatar Feb 22 '21 08:02 aliakbarazizi