Open DavidOliver opened 12 years ago
Hmm yes, this is most likely more of a Symphony bug, I think. It will try to join the SBL table multiple times, which is unnecessary. You should create an array of the keys you want to filter on, and set the where
once:
$keys = array();
foreach ($_SESSION['sym-cart'] as $key => $item) {
$keys[] = $key;
}
$products_query->where('instances', implode(', ', $keys));
I think this will work as Symphony will take the comma delimited string of IDs and converts it to an array.
Nick, I see - thanks.
I'm now getting product entry objects, but they're the wrong ones. Instead of the two products that contain the instances given, I'm getting three products that have nothing to do with the instances. (My "instances" are versions of products.)
I've checked that the implode
is giving the right instance ids.
@DavidOliver Pull Request ? :P
Version: 0.6.2 (Symphony 2.2.5)
I have the following in an event:
The
instances
field is a SBL+ field.When there is more than one product in the cart, meaning
->where
is called more than once, and the event is triggered:Symphony Fatal Database Error Not unique table/alias: 't137' An error occurred while attempting to execute the following query SELECT SQL_CACHE
e
.id,e
.section_id, e.author_id
, UNIX_TIMESTAMP(e.creation_date
) AScreation_date
FROMsym_entries
ASe
LEFT JOINsym_entries_data_137
ASt137
ON (e
.id
=t137
.entry_id) LEFT JOINsym_entries_data_137
ASt137
ON (e
.id
=t137
.entry_id) WHERE 1 ANDe
.section_id
= '1' ANDt137
.relation_id IN ('1723') ANDt137
.relation_id IN ('3096') ORDER BYe
.id
DESC LIMIT 0, 999The
t137
alias is created more than once.When
->where
is called multiple times usingsystem:id
, this error doesn't occur.