SELECT d . * FROM DestinationNames d JOIN ( SELECT LENGTH( Number ) AS maxlen, number FROM DestinationNames d WHERE '019235678910' LIKE CONCAT( Number, '%' ) ORDER BY maxlen DESC LIMIT 1 )dsum ON d.Number = dsum.Number
$c = $modx->myDB->newQuery('DestinationNames');
$c->select(d . *);
$c->from(DestinationNames d);
$c->innerjoin(); ???
$c->select(LENGTH( Number ) AS maxlen, number);
$c->from(DestinationNames d)
$c->where( '019235678910' LIKE CONCAT( Number, '%' ) );
$c->sortby(maxlen DESC );
$c->limit( 1);
???? )dsum ON d.Number = dsum.Number
This question has been answered by mflammia. See the first response.
$query ='
SELECT d . *
FROM DestinationNames d
JOIN (
SELECT LENGTH( Number ) AS maxlen, number
FROM DestinationNames d
WHERE '019235678910' LIKE CONCAT( Number, '%' )
ORDER BY maxlen DESC
LIMIT 1
)dsum ON d.Number = dsum.Number';
$criteria = new xPDOCriteria($modx, $query);
If ($results = $modx->myDB->getCollection('DestinationNames', $criteria)) {
foreach ($results as $result) {
$fields = $result->toArray();
$rows[] = $modx->getChunk('tpl.ShowDataDestinationNames', $fields);
}
$ph['rows'] = implode('', $rows);
$output = $modx->getChunk('tpl.ShowDataOuterDestinationNames', $ph);
} else {
$output = $noresults;
}
}
return $output;
Parse error: syntax error, unexpected T_LNUMBER in /home/sites/domain.co.uk/public_html/nhs/core/cache/includes/elements/modsnippet/39.include.cache.php on line 42
$query = "SELECT d . *
FROM DestinationNames d
JOIN (
SELECT LENGTH( Number ) AS maxlen, number
FROM DestinationNames d
WHERE '019235678910' LIKE CONCAT( Number, '%' )
ORDER BY maxlen DESC
LIMIT 1
)dsum ON d.Number = dsum.Number";