Hello,
i’ve tried another statement which is not working even i put $x->select() At the end.
First attempt:
<?php
$t = $this->modx->newQuery('modTemplateVar');
$t->setClassAlias('tv');
$t->select(array(
'name' => 'tv.name',
'type' => 'tv.type',
'contentid' => 'tvValues.contentid',
'display' => 'tv.display',
'display_params' => 'tv.display_params',
'value' => 'tvValues.value',
));
$t->leftJoin('modTemplateVarResource','tvValues','tv.id = tvValues.tmplvarid');
$t->leftJoin('modResource','content','tvValues.contentid = content.id');
$t->where(array(
'tv.name' => $tvTags,
"tvValues.contentid IN (" . implode($cIDs,",") . ")",
'content.pub_date:>=' => $pub_date,
'content.published' => 1,
));
$t->sortby('tvValues.contentid','ASC');
$tags = $this->modx->getCollection('modTemplateVar',$t);
?>
Second Attempt:
<?php
$t = $this->modx->newQuery('modTemplateVar');
$t->leftJoin('modTemplateVarResource','tvValues','tv.id = tvValues.tmplvarid');
$t->leftJoin('modResource','content','tvValues.contentid = content.id');
$t->where(array(
'tv.name' => $tvTags,
"tvValues.contentid IN (" . implode($cIDs,",") . ")",
'content.pub_date:>=' => $pub_date,
'content.published' => 1,
));
$t->sortby('tvValues.contentid','ASC');
$t->setClassAlias('tv');
$t->select(array(
'name' => 'tv.name',
'type' => 'tv.type',
'contentid' => 'tvValues.contentid',
'display' => 'tv.display',
'display_params' => 'tv.display_params',
'value' => 'tvValues.value',
));
$tags = $this->modx->getCollection('modTemplateVar',$t);
?>
Both test return in any browser that the connection has been reinitialized.
If i debug both by using:
<?php
$t->prepare();
$debug = $t->toSQL();
echo $debug;
?>
And past the result in SQLYog it work for both.
As i said above, i’ve find another way to achieve a similar result with less code, but it would be interesting to know why it does not work that way too?