S
S
Sergey2017-07-28 17:48:51
MODX
Sergey, 2017-07-28 17:48:51

Get max value from tvVar?

How to get the maximum value of an additional field, for the entire table 'modx_site_tmplvar_contentvalues'?
I'm trying to do this, I want to get its id by the field name, and already by id, make a request for max.
The problem is that this query works.

$stmt = $modx->query("SELECT MAX(value) FROM `modx_site_tmplvar_contentvalues` WHERE `tmplvarid` = 34");
$maxId = $stmt->fetch(PDO::FETCH_COLUMN);

and similar to get id, no
$stmt = $modx->query("SELECT id FROM `modx_site_tmplvars` WHERE `name` = price");
$id = $stmt->fetch(PDO::FETCH_COLUMN);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question