Created
June 17, 2020 06:54
-
-
Save qwertik17/f49cd4f83a0edbee890b5606c553f4aa to your computer and use it in GitHub Desktop.
Получаем все уникальные значения ТВ во всех ресурсах
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$res = array(); | |
$q = $modx->newQuery('modTemplateVarResource', array('tmplvarid' => $tv_id)); | |
$template_id = 28; | |
$template_id = explode(',',$template_id); | |
$q->innerJoin('modResource', 'modResource', "modResource.id = modTemplateVarResource.contentid"); | |
$q->select('contentid,value,modResource.template'); | |
$q->where(array( | |
'modResource.template:IN' => $template_id, | |
'modResource.published' => 1, | |
'modResource.deleted' => 0 | |
)); | |
$q->groupby('value'); | |
if ($q->prepare() && $q->stmt->execute()) { | |
while ($row = $q->stmt->fetch(PDO::FETCH_ASSOC)) { | |
$res[$row['contentid']] = $row['value']; | |
} | |
} | |
$result = implode('||',$res); | |
$result = explode('||',$result); | |
$result = array_unique($result); | |
$result = implode('||',$result); | |
return $result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment