Skip to content

Commit

Permalink
Fixed issue #15571: CPDB - cannot use the search boxes below associat…
Browse files Browse the repository at this point in the history
…ed to the additional attributes
  • Loading branch information
Trischi80 committed Dec 4, 2019
1 parent f3ad76f commit 5fd3646
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions application/models/Participant.php
Expand Up @@ -510,22 +510,22 @@ public function search()
$attributeId = (int) substr($attributeId, 3);

/** @var string Param name to bind in prepared statement */
$bindKey = ':attribute_id' . $attributeId;

$callParticipantAttributes = Yii::app()->db->createCommand()
->selectDistinct('pa.participant_id')
->from('{{participant_attribute}} AS pa')
->where('attribute_id='.$bindKey, array($bindKey => $attributeId));
->from('{{participant_attribute}} AS pa');
// NB: Binding in andWhere() is not enough since the subquery is converted to string.
// See: https://forum.yiiframework.com/t/show-sql-generated-from-cdbcriteria/45021
$criteria->params[$bindKey] = $attributeId;

// Use "LIKE" for text-box, equal for other types
if ($attributeType == 'TB') {
$callParticipantAttributes->andWhere('like', 'value', '%' . $value . '%');
$bindKey = ':attribute_id' . $attributeId;
$callParticipantAttributes->where("attribute_id = " . $bindKey . " AND value LIKE '%" . $value . "%'", array($bindKey => $attributeId));
$criteria->params[$bindKey] = $attributeId;
} else {
/** @var string Param name to bind in prepared statement */
$bindKey = ':value' . $attributeId;
$callParticipantAttributes->andWhere('value = ' . $bindKey, array($bindKey => $value));
$callParticipantAttributes->where("attribute_id = '" . $attributeId . "' AND value = " . $bindKey , array($bindKey => $value));
// NB: Binding in andWhere() is not enough since the subquery is converted to string.
$criteria->params[$bindKey] = $value;
}
Expand Down

1 comment on commit 5fd3646

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge issue in develop ;) (unsure)

Please sign in to comment.