sottwell Reply #1, 4 months, 1 week ago
I had occasion to use "key" as a field name. Because "key" is a MySQL reserved word, it caused a MySQL error when using this query
To solve the problem, since I really did want the field name to be "key", I changed the sort specification line to quote the field name:
http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html
$sort = $modx->getOption('sort',$scriptProperties,'key');
$dir = $modx->getOption('dir',$scriptProperties,'ASC');
$c = $modx->newQuery('Coupon');
$c->sortby($sort,$dir);
$coupons = $modx->getCollection('Coupon',$c);
To solve the problem, since I really did want the field name to be "key", I changed the sort specification line to quote the field name:
$sort = $modx->getOption('sort',$scriptProperties,'`key`');http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html