Jump to content

SQL question


mohsart

Recommended Posts

I was never very good at SQL and I am quite rusty now. Anyways, if someone could have a look, I'd apreciate it!

 

In classes/Supplier.php I have

   	 $query = new DbQuery();
	$query->select('s.*, sl.`description`, a.`address1`');
	$query->from('supplier', 's');
	$query->leftJoin('supplier_lang', 'sl', 's.`id_supplier` = sl.`id_supplier` AND sl.`id_lang` = '.(int)$id_lang);

$query->leftJoin('address', 'a', 's.`id_supplier` = a.`id_supplier`');

	$query->join(Shop::addSqlAssociation('supplier', 's'));
	if ($active)
		$query->where('s.`active` = 1');
	$query->orderBy(' s.`name` ASC');
	$query->limit($n, ($p - 1) * $n);
	$query->groupBy('s.id_supplier');

	$suppliers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);

The idea is that the field address1 in db table address should be added to the $supplier array.

 

Am I totally off track here or is it a simple mistake?

Edit:

On line 2 ", a.`address1`" is added

Line 5 is added

 

/Mats

Edited by mohsart (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...